제출 #1025071

#제출 시각아이디문제언어결과실행 시간메모리
1025071ByeWorld세 명의 친구들 (BOI14_friends)C++14
100 / 100
58 ms6444 KiB
#include <bits/stdc++.h> // #define int long long #define ll long long #define pb push_back #define fi first #define se second using namespace std; typedef pair<int,int> pii; typedef pair<int,pii> ipii; const int MAXN = 2e6+15; // const int INF = 2e18+10; int n; string s; bool dep=0, bel=0; signed main(){ cin >> n; cin >> s; s = '.'+s; if(n%2==0){ cout << "NOT POSSIBLE\n"; exit(0); } int i, j = n/2+1; for(i=1; i<=n/2; i++){ if(s[i]==s[j]) j++; else break; } dep = 1; j++; // s[j] blm, s[i] blm for(; i<=n/2; i++, j++) if(s[i]!=s[j]) dep = 0; j = 1; for(i=n/2+2; i<=n; i++){ if(s[i]==s[j]) j++; else break; } bel = 1; j++; for(; i<=n; i++, j++) if(s[i]!=s[j]) bel = 0; bool can = 1; for(int i=1; i<=n/2; i++){ if(s[i]!=s[i+n/2+1]) can = 0; } if(can){ dep = 1; bel = 0; } if(!dep && !bel) cout << "NOT POSSIBLE\n"; else if(dep && bel) cout << "NOT UNIQUE\n"; else if(dep){ for(int i=1; i<=n/2; i++) cout << s[i]; cout << '\n'; } else { for(int i=n/2+2; i<=n; i++) cout << s[i]; cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...