-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.cpp
37 lines (36 loc) · 907 Bytes
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const auto IO_ = [] {
return ios::sync_with_stdio(false), cin.tie(nullptr);
}();
signed main() {
string s;
cin >> s;
int n = int(s.size());
string ans;
auto No = [&]() {
cout << "No solution";
exit(0);
};
if (s.find('@') == string::npos) No();
for (int i = 0; i < n; ) {
if (s[i] == '@') {
if (i == n - 1 || s[i + 1] == '@' || ans.empty() || ans.back() == ',') No();
ans += s[i];
ans += s[i + 1];
if (s.find('@', i + 2) == string::npos) {
ans += s.substr(i + 2);
break;
} else {
ans += ',';
}
i += 2;
} else {
ans += s[i];
++i;
}
}
cout << ans;
return 0;
}