# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382891 | 2021-03-28T11:20:53 Z | abil | Three Friends (BOI14_friends) | C++14 | 164 ms | 262148 KB |
#include <bits/stdc++.h> #define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() #define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int inf = (1e9 + 7); string p[N]; main(){ SPEEDUP; int n; cin >> n; string s; cin >> s; if(!(n & 1)){ cout << "NOT POSSIBLE"; return 0; } string a = "", b = ""; for(int j = n / 2 + 1; j < n; j++){ b.pb(s[j]); } for(int i = n / 2; i >= 0; i--){ p[i] = a; a = s[i] + a; } a = ""; vector<string > ans; for(int i = 0;i <= n / 2; i++){ if(a + p[i] == b){ ans.pb(b); } a.pb(s[i]); } b = ""; a = ""; for(int i = 0;i < n / 2; i++){ a.pb(s[i]); } for(int i = n / 2; i < n; i++){ p[i] = b; b.pb(s[i]); } b = ""; for(int i = n / 2; i < n; i++){ if(b + p[i] == a){ ans.pb(a); } b.pb(s[i]); } if(ans.size() > 1){ cout << "NOT UNIQUE"; return 0; } if(ans.empty()){ cout << "NOT POSSIBLE"; return 0; } cout << ans[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 31596 KB | Output is correct |
2 | Correct | 20 ms | 31616 KB | Output is correct |
3 | Correct | 20 ms | 31596 KB | Output is correct |
4 | Correct | 20 ms | 31596 KB | Output is correct |
5 | Incorrect | 20 ms | 31596 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 164 ms | 262148 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |