제출 #372753

#제출 시각아이디문제언어결과실행 시간메모리
372753FatihSolak세 명의 친구들 (BOI14_friends)C++17
100 / 100
25 ms8080 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout);s int n; cin >> n; string s; cin >> s; int l = (n-1)/2; if((n%2) == 0){ cout << "NOT POSSIBLE"; return 0; } string ans1="",ans2=""; for(int i=0;i<l;i++){ ans1+=s[i]; } for(int i=l+1;i<n;i++){ ans2+=s[i]; } bool ok1=0,ok2=0; int cnt = 0; for(int i=l;i<n && cnt<l;i++){ if(ans1[cnt] == s[i]){ cnt++; } } ok1 = (cnt == l); cnt = 0; for(int i=0;i<=l && cnt<l;i++){ if(ans2[cnt] == s[i]){ cnt++; } } ok2 = (cnt ==l); if(!ok1 && !ok2){ cout << "NOT POSSIBLE"; return 0; } if(ok1 && ok2 && (ans1 != ans2)){ cout << "NOT UNIQUE"; return 0; } if(ok1){ cout << ans1; return 0; } cout << ans2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...