Submission #1126408

#TimeUsernameProblemLanguageResultExecution timeMemory
1126408AgageldiThree Friends (BOI14_friends)C++20
0 / 100
1094 ms5348 KiB
/* ID: agageld1 LANG: C++17 TASK: */ #include <bits/stdc++.h> using namespace std; #define ll long long #define N 400005 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define rep(c, a, b) for(c = a; c <= b; c++) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll n, t, a[N]; string s, g; vector <string> v, h; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n >> s; if(n%2 == 0 || n == 1) { cout << "NOT POSSIBLE"; return 0; } for(int i = 0; i < n; i++) { g = ""; v.clear(); for(int j = 0;j<n;j++) { if(j == i) continue; g += s[j]; if(sz(g) == (n / 2)) { v.pb(g); g = ""; } } assert(sz(v[0]) == sz(v[1])); if(v[0] == v[1])h.pb(v[0]); } if(!sz(h)) { cout << "NOT POSSIBLE"; return 0; } bool tr = 0; for(int i = 0; i < sz(h); i++) { int cnt = 0; for(int j = 0;j<sz(h);j++) { if(i == j) continue; if(h[i] != h[j]) cnt++; } if(cnt == sz(h) - 1) { cout << h[i] << '\n'; return 0; } } cout << "NOT UNIQUE"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...