Algorithm


A. Jabber ID
time limit per test
0.5 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where

  • <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
  • <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
  • <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.

The content of square brackets is optional — it can be present or can be absent.

There are the samples of correct Jabber IDs: mike@codeforces.com007@en.codeforces.com/contest.

Your task is to write program which checks if given string is a correct Jabber ID.

Input

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

Output

Print YES or NO.

Examples
input
Copy
mike@codeforces.com
output
Copy
YES
input
Copy
john.smith@codeforces.ru/contest.icpc/12
output
Copy
NO

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int const N = 1e5 + 1;
long long const M = 1e5 * 1e6 + 1;
int n, m, parent[N];
long long cost[N];
bool vis[N];
vector<vector<pair<int, int> > > g;
vector<int> res;
priority_queue<pair<long long, int> > qu;

void Dijkstra(int src) {
    while(!qu.empty()) qu.pop();
    for(int i = 0; i < n; i++) cost[i] = M;
    cost[src] = 0;
    qu.push(make_pair(0, src));
    
    while(!qu.empty()) {
        int v = qu.top().second;
        long long c = -qu.top().first;
        
        qu.pop();
        if(vis[v]) continue;
        vis[v] = true;
        
        for(int i = 0; i < g[v].size(); i++)
            if(g[v][i].second + c < cost[g[v][i].first]) {
                parent[g[v][i].first] = v;
                cost[g[v][i].first] = g[v][i].second + c;
                qu.push(make_pair(-(g[v][i].second + c), g[v][i].first));
            }
    }
}

int main() {
    int u, v, c;
    
    cin >> n >> m;
    g.resize(n);
    
    for(int i = 0; i < m; i++) {
        cin >> u >> v >> c;
        u--; v--;
        g[u].push_back(make_pair(v, c));
        g[v].push_back(make_pair(u, c));
    }
    
    Dijkstra(0);
    
    if(cost[n - 1] == M) cout << -1 << endl;
    else {
        v = n - 1;
        
        while (v != 0) {
            res.push_back(v + 1);
            v = parent[v];
        }
        
        res.push_back(1);

        for (int i = res.size() - 1; i >= 0; i--) cout << res[i] << ' ';
        cout << endl;
    }
    
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
mike@codeforces.com

Output

x
+
cmd
YES
Advertisements

Demonstration


Codeforcess Solution 21A. Jabber IDC,C++, Java, Js and Python ,21A. Jabber,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+