Submission #653140

#TimeUsernameProblemLanguageResultExecution timeMemory
653140aryan12Three Friends (BOI14_friends)C++17
100 / 100
52 ms6072 KiB
#include<iostream> using namespace std; string s,t; int l,r,i,p,n,f,g; bool c(){p=0;for(i=l;i<=r;i++){if(p!=t.size()&&t[p]==s[i])p++;}return(p==t.size());}int main(){cin>>n>>s;if(!(n&1)){cout << "NOT POSSIBLE";return 0;}t=s.substr(0,n/2);l=n/2;r=n-1;f=c();t=s.substr(n-n/2,n/2);l=0;r=n/2;g=c();if(!f&&!g)cout<<"NOT POSSIBLE";else if(f&&g&&s.substr(0,n/2)!=s.substr(n-n/2,n/2))cout<<"NOT UNIQUE";else if(f)cout<<s.substr(0,n/2);else cout<<s.substr(n-n/2,n/2);}

Compilation message (stderr)

friends.cpp: In function 'bool c()':
friends.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | bool c(){p=0;for(i=l;i<=r;i++){if(p!=t.size()&&t[p]==s[i])p++;}return(p==t.size());}int main(){cin>>n>>s;if(!(n&1)){cout << "NOT POSSIBLE";return 0;}t=s.substr(0,n/2);l=n/2;r=n-1;f=c();t=s.substr(n-n/2,n/2);l=0;r=n/2;g=c();if(!f&&!g)cout<<"NOT POSSIBLE";else if(f&&g&&s.substr(0,n/2)!=s.substr(n-n/2,n/2))cout<<"NOT UNIQUE";else if(f)cout<<s.substr(0,n/2);else cout<<s.substr(n-n/2,n/2);}
      |                                   ~^~~~~~~~~~
friends.cpp:5:72: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | bool c(){p=0;for(i=l;i<=r;i++){if(p!=t.size()&&t[p]==s[i])p++;}return(p==t.size());}int main(){cin>>n>>s;if(!(n&1)){cout << "NOT POSSIBLE";return 0;}t=s.substr(0,n/2);l=n/2;r=n-1;f=c();t=s.substr(n-n/2,n/2);l=0;r=n/2;g=c();if(!f&&!g)cout<<"NOT POSSIBLE";else if(f&&g&&s.substr(0,n/2)!=s.substr(n-n/2,n/2))cout<<"NOT UNIQUE";else if(f)cout<<s.substr(0,n/2);else cout<<s.substr(n-n/2,n/2);}
      |                                                                       ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...