제출 #398868

#제출 시각아이디문제언어결과실행 시간메모리
398868almosabhali세 명의 친구들 (BOI14_friends)C++14
0 / 100
45 ms15888 KiB
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int counter[26]; int main() { fast(); int n; string s; cin>>n>>s; for(char c:s) counter[c-'A']++; int odd=0; char index; for(int i=0;i<26;i++) { odd+=(counter[i]%2); if(counter[i]%2) index=i+'A'; } if(odd!=1) cout<<"NOT POSSIBLE\n"; else { // cout<<"debug\n"; string ans1,ans2; bool f=0; string res1,res2; string l=s.substr(0,n/2),r=s.substr(n/2+1,n/2+1); f=0; res1.clear(); res2.clear(); string _l=l+s[n/2],_r=r; for(int i=0;i<n/2;i++) { // cout<<_l[i]<<' '<<_r[i+f]<<'\n'; if(_l[i+f]!=_r[i]) f=1; res1+=_l[i+f]; res2+=_r[i]; } ans1=(res1 == res2 ? res1 : ""); f=0; res1.clear(); res2.clear(); _l.pop_back(); _r=s[n/2]+_r; for(int i=0;i<n/2;i++) { // cout<<_r[i]<<' '<<_l[i+f]<<'\n'; if(_r[i]!=_l[i+f]) f=1; res1+=_r[i]; res2+=_l[i+f]; } ans2=(res1 == res2 ? res1 : ""); if(ans1.size() && ans2.size() && ans1!=ans2) cout<<"NOT UNIQUE\n"; else if(!ans1.size() && !ans2.size()) cout<<"NOT POSSIBLE\n"; else cout<<ans1+ans2<<'\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'int main()':
friends.cpp:16:10: warning: variable 'index' set but not used [-Wunused-but-set-variable]
   16 |     char index;
      |          ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...