fork download
  1. // To understand what is happening in this file, please go to the end of the file.
  2.  
  3. #include "bits/stdc++.h"
  4.  
  5. #define int long long
  6. #define vi vector< int >
  7. #define fastIO() ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  8. #define all(x) x.begin(),x.end()
  9. #define endl '\n'
  10.  
  11. using namespace std;
  12.  
  13. /*
  14.  
  15.  
  16.   ▄████ ██▓ ██▓▄▄▄█████▓ ▄████▄ ██░ ██
  17.  ██▒ ▀█▒▓██▒ ▓██▒▓ ██▒ ▓▒▒██▀ ▀█ ▓██░ ██▒
  18. ▒██░▄▄▄░▒██░ ▒██▒▒ ▓██░ ▒░▒▓█ ▄ ▒██▀▀██░
  19. ░▓█ ██▓▒██░ ░██░░ ▓██▓ ░ ▒▓▓▄ ▄██▒░▓█ ░██
  20. ░▒▓███▀▒░██████▒░██░ ▒██▒ ░ ▒ ▓███▀ ░░▓█▒░██▓
  21.  ░▒ ▒ ░ ▒░▓ ░░▓ ▒ ░░ ░ ░▒ ▒ ░ ▒ ░░▒░▒
  22.   ░ ░ ░ ░ ▒ ░ ▒ ░ ░ ░ ▒ ▒ ░▒░ ░
  23. ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░
  24.   ░ ░ ░ ░ ░ ░ ░ ░ ░
  25.  
  26. */
  27.  
  28. template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
  29. template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
  30.  
  31.  
  32.  
  33. void itIsADream(){
  34. string s; cin >> s;
  35. int n = s.size();
  36.  
  37. vi pos;
  38. for (int i = 0; i < n; i++) {
  39. if (s[i] == '@') {
  40. pos.push_back(i);
  41. }
  42. }
  43.  
  44. int m = pos.size();
  45. if (pos.empty() || pos[0] == 0 || pos.back() == n - 1) {
  46. cout << "No solution" << endl;
  47. return;
  48. }
  49.  
  50. for (int i = 0; i < m - 1; i++) {
  51. if (pos[i + 1] - pos[i] < 3) {
  52. cout << "No solution" << endl;
  53. return;
  54. }
  55. }
  56.  
  57. string ans = "";
  58. int cur = 0;
  59.  
  60. for (int i = 0; i < m; i++) {
  61. int end;
  62.  
  63. if (i == m - 1) {
  64. end = n - 1;
  65. } else {
  66. end = pos[i] + 1;
  67. }
  68.  
  69. ans += s.substr(cur, end - cur + 1);
  70.  
  71. if (i < (int)m - 1) {
  72. ans += ",";
  73. }
  74.  
  75. cur = end + 1;
  76. }
  77.  
  78. cout << ans << endl;
  79. }
  80.  
  81. int32_t main()
  82. {
  83. fastIO();
  84. // freopen("input.txt", "r", stdin);
  85. // freopen("output.txt", "w", stdout);
  86. int t = 1;
  87. // cin >> t;
  88. while (t--)
  89. {
  90. itIsADream();
  91. }
  92. return 0;
  93. }
  94.  
  95. // to understand what is happening in this file, please go to the starting of the file.
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
No solution