제출 #944693

#제출 시각아이디문제언어결과실행 시간메모리
944693tamir1세 명의 친구들 (BOI14_friends)C++17
100 / 100
34 ms10948 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll n,i; string ans="",u,s,t; bool check(string s,string t){ ll n=s.size(),i,j=0; bool a=1; for(i=0;i<n;i++){ if(s[i]==t[j]){ j++; continue; } else if(a){ j++; a=0; if(s[i]!=t[j]) return 0; else j++; } else return 0; } return 1; } int main(){ cin >> n >> u; if(n%2==0){ cout << "NOT POSSIBLE"; return 0; } s=u.substr(0,n/2); t=u.substr(n/2,n); if(check(s,t)) ans=s; s=u.substr(n/2+1,n); t=u.substr(0,n/2+1); if(check(s,t)){ if(ans=="" || ans==s) cout << s; else cout << "NOT UNIQUE"; } else if(ans=="") cout << "NOT POSSIBLE"; else cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...