Algorithm


B. Sysadmin Bob
time limit per test
0.5 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.

Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order, separated by commas. The same address can be written more than once.

Suddenly, because of unknown reasons, all commas in Bob's list disappeared. Now Bob has a string, where all addresses are written one after another without any separators, and there is impossible to determine, where the boundaries between addresses are. Unfortunately, on the same day his chief asked him to bring the initial list of addresses. Now Bob wants to disjoin addresses in some valid way. Help him to do that.

Input

The first line contains the list of addresses without separators. The length of this string is between 1 and 200, inclusive. The string consists only from small Latin letters and characters «@».

Output

If there is no list of the valid (according to the Berland rules) email addresses such that after removing all commas it coincides with the given string, output No solution. In the other case, output the list. The same address can be written in this list more than once. If there are several solutions, output any of them.

Examples
input
Copy
a@aa@a
output
Copy
a@a,a@a
input
Copy
a@a@a
output
Copy
No solution
input
Copy
@aa@a
output
Copy
No solution

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <vector>

int main(){

    std::string db; std::cin >> db;
    bool sol(true);
    std::vector<std::string> dv;
    std::string cur; bool gat(false);
    for(long p = 0; p < db.size(); p++){
        cur += db[p];
        if(db[p] == '@'){
            if(gat || (cur.size() == 1) || (p + 2 > db.size())){sol = false; break;}; 
            gat = true;
        }
        else if(gat){dv.push_back(cur); cur = ""; gat = false;}
    }

    if(dv.size() > 0 && cur.size() > 0 && !gat){dv.back() += cur;}
    else if(dv.size() <= 0){sol = false;}

    if(sol){for(long p = 0; p < dv.size(); p++){std::cout << dv[p] << ((p + 1 < dv.size()) ? "," : "\n");}}
    else{std::cout << "No solution" << std::endl;}

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
a@aa@a

Output

x
+
cmd
a@a,a@a
Advertisements

Demonstration


Codeforces Solution-B. Sysadmin Bob-Solution in C, C++, Java, Python

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