Submission #1126422

#TimeUsernameProblemLanguageResultExecution timeMemory
1126422AgageldiThree Friends (BOI14_friends)C++20
0 / 100
18 ms7228 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], p = 0; string s, g, ans; void solve(string h) { int cnt = 0, tr = 0; for(int i = 0; i < sz(s); i++) { if(cnt == sz(h)) break; if(h[cnt] == s[i]) cnt++; else { tr++; if(tr == 2) break; } } if(tr <= 1) p = 1; } int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n >> s; if(n % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } for(int i = 0; i < n/2; i++) { g += s[i]; } int f = 0; solve(g + g); if(p) { ans = g; f++; } g = ""; for(int i = n/2 + 1; i < n; i++) { g += s[i]; } p = 0; solve(g + g); if(p) { ans = g; f++; } if(!f) cout << "NOT POSSIBLE\n"; if(f == 2) cout << "NOT UNIQUE\n"; else cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...