제출 #535135

#제출 시각아이디문제언어결과실행 시간메모리
535135new_acc세 명의 친구들 (BOI14_friends)C++14
100 / 100
68 ms9092 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int N=2e6+10; string s; void solve(){ int n; cin>>n; cin>>s; n=s.size(); string s1,s2; if(n%2==0){ cout<<"NOT POSSIBLE\n"; return; } for(int i=0;i<n/2;i++) s1+=s[i]; for(int i=n/2+1;i<s.size();i++) s2+=s[i]; bool ok=1,byl=0,ile=0; int wsk=0; for(int i=n/2;i<s.size();i++){ if(wsk==s1.size()) break; if(s[i]==s1[wsk]) wsk++; else{ if(byl) ok=0; else byl=1; } } if(ok) ile=1; wsk=0,ok=1,byl=0; for(int i=0;i<=n/2;i++){ if(wsk==s2.size()) break; if(s[i]==s2[wsk]) wsk++; else{ if(byl) ok=0; else byl=1; } } if(ok and ile and s1!=s2) cout<<"NOT UNIQUE\n"; else{ if(ok) cout<<s2<<"\n"; else{ if(ile) cout<<s1<<"\n"; else cout<<"NOT POSSIBLE\n"; } } } int main(){ solve(); }

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

friends.cpp: In function 'void solve()':
friends.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=n/2+1;i<s.size();i++) s2+=s[i];
      |                  ~^~~~~~~~~
friends.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=n/2;i<s.size();i++){
      |                ~^~~~~~~~~
friends.cpp:25:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if(wsk==s1.size()) break;
      |      ~~~^~~~~~~~~~~
friends.cpp:35:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   if(wsk==s2.size()) break;
      |      ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...