# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26465 | 2017-07-01T05:44:15 Z | WhipppedCream | Three Friends (BOI14_friends) | C++14 | 79 ms | 3972 KB |
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back #define mp make_pair typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii; typedef long long L; typedef vector< L > vL; typedef vector< vL > vvL; typedef vector< vi > vvi; typedef vector< vii > vvii; const int inf = 1e9; const L inf8 = 1e18; const int maxn = 2e6 + 5; const int md = 1e9 + 7; void np() { puts("NOT POSSIBLE"); exit(0); } void nu() { puts("NOT UNIQUE"); exit(0); } char s[maxn]; int main() { int n; scanf("%d", &n); scanf("%s", s); if(n%2 == 0 || n<= 2) np(); int a = 0, b = 0; int skipped = 0; int ptr = n/2; bool bad = 0; for(int i = 0; i< n/2; i++) { if(s[i] == s[ptr]) ptr++; else if(!skipped) { skipped = 1; i--; ptr++; } else { bad = 1; break; } } if(!bad) a = 1; skipped = 0; bad = 0; ptr = 0; for(int i = n/2+1; i< n; i++) { if(s[i] == s[ptr]) ptr++; else if(!skipped) { skipped = 1; i--; ptr++; } else { bad = 1; break; } } if(!bad) b = 1; if(a&&b) nu(); if(a+b == 0) np(); if(a) for(int i = 0; i< n/2; i++) printf("%c", s[i]); else for(int i = n/2+1; i< n; i++) printf("%c", s[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3972 KB | Output is correct |
2 | Correct | 0 ms | 3972 KB | Output is correct |
3 | Correct | 0 ms | 3972 KB | Output is correct |
4 | Incorrect | 0 ms | 3972 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 3972 KB | Output is correct |
2 | Correct | 73 ms | 3972 KB | Output is correct |
3 | Correct | 63 ms | 3972 KB | Output is correct |
4 | Correct | 79 ms | 3972 KB | Output is correct |
5 | Correct | 66 ms | 3972 KB | Output is correct |
6 | Correct | 9 ms | 3972 KB | Output is correct |
7 | Incorrect | 6 ms | 3972 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |