Submission #958610

#TimeUsernameProblemLanguageResultExecution timeMemory
958610pccThree Friends (BOI14_friends)C++17
100 / 100
8 ms8252 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 2e6+10; int n; string s; string ans; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>s; if(n%2==0){ cout<<"NOT POSSIBLE\n"; return 0; } string ts = s.substr(0,n/2); int pt = 0; for(int i = n/2;i<n;i++){ if(pt != ts.size()&&s[i] == ts[pt])pt++; } if(pt == ts.size())ans = ts; ts = s.substr(n-n/2,n/2); pt = 0; for(int i = 0;i<=n/2;i++){ if(pt != ts.size()&&ts[pt] == s[i])pt++; } if(pt == ts.size()){ if(pt =!ans.empty()&&ans != ts){ cout<<"NOT UNIQUE\n"; return 0; } ans = ts; } cout<<(ans.empty()?"NOT POSSIBLE":ans)<<'\n'; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:27:9: 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(pt != ts.size()&&s[i] == ts[pt])pt++;
      |      ~~~^~~~~~~~~~~~
friends.cpp:29:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  if(pt == ts.size())ans = ts;
      |     ~~~^~~~~~~~~~~~
friends.cpp:33:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if(pt != ts.size()&&ts[pt] == s[i])pt++;
      |      ~~~^~~~~~~~~~~~
friends.cpp:35:8: 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(pt == ts.size()){
      |     ~~~^~~~~~~~~~~~
friends.cpp:36:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   36 |   if(pt =!ans.empty()&&ans != ts){
      |      ~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...