제출 #154438

#제출 시각아이디문제언어결과실행 시간메모리
154438brcode세 명의 친구들 (BOI14_friends)C++14
0 / 100
131 ms8240 KiB
#include <iostream> using namespace std; string res; string res2; bool ans1 = true; bool ans2 = true; int main(){ int n; cin>>n; string s; cin>>s; s='#'+s; int mid = (s.length()+1)/2; int sz = (s.length()-1)/2; int temp = mid+1; bool ok = false; int j = 1; int cnt = 1; while(cnt<=sz){ if(s[j]!=s[temp]){ if(ok){ ans1= false; break; }else{ ok = true; j++; } }else{ temp++; j++; cnt++; } } ok = false; temp= mid; j=1; cnt = 1; while(cnt<=sz){ if(s[j]!=s[temp]){ if(ok){ ans2 = false; break; }else{ ok = true; temp++; } }else{ temp++; j++; cnt++; } } if((!ans1 && !ans2)||s.length()%2 == 1){ cout<<"NOT POSSIBLE"<<endl; }else if(!ans2){ for(int i=mid+1;i<=s.length();i++){ res+=s[i]; } cout<<res<<endl; }else if(!ans1){ for(int i=1;i<=sz;i++){ res+=s[i]; } cout<<res<<endl; }else{ for(int i=mid+1;i<=s.length();i++){ res+=s[i]; } for(int i=1;i<=sz;i++){ res2+=s[i]; } if(res == res2){ cout<<res<<endl; }else{ cout<<"NOT UNIQUE"<<endl; } } }

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

friends.cpp: In function 'int main()':
friends.cpp:60:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=mid+1;i<=s.length();i++){
                         ~^~~~~~~~~~~~
friends.cpp:70:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          for(int i=mid+1;i<=s.length();i++){
                          ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...