Submission #996277

#TimeUsernameProblemLanguageResultExecution timeMemory
996277SuPythonyThree Friends (BOI14_friends)C++17
100 / 100
39 ms11068 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; string s; cin>>s; if (n%2==0) cout<<"NOT POSSIBLE"; else { string l=s.substr(0,(n-1)/2), r=s.substr((n-1)/2+1,(n-1)/2); string lc=s.substr((n-1)/2,(n-1)/2+1), rc=s.substr(0,(n-1)/2+1); vector<string> ans; int ind=0; bool wrong=false; bool pos=true; for (char i: lc) { if (i!=l[ind]) { if (!wrong) { wrong=true; continue; } else { pos=false; break; } } ind++; if (ind==lc.size()) break; } if (pos) ans.push_back(l); ind=0; wrong=false; pos=true; for (char i: rc) { if (i!=r[ind]) { if (!wrong) { wrong=true; continue; } else { pos=false; break; } } ind++; if (ind==rc.size()) break; } if (pos) ans.push_back(r); if (ans.empty()) cout<<"NOT POSSIBLE"; else if (ans.size()>1&&ans[0]!=ans[1]) cout<<"NOT UNIQUE"; else cout<<ans[0]; } return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (ind==lc.size()) break;
      |                 ~~~^~~~~~~~~~~
friends.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if (ind==rc.size()) break;
      |                 ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...