Submission #398943

#TimeUsernameProblemLanguageResultExecution timeMemory
398943katwamiawThree Friends (BOI14_friends)C++14
100 / 100
73 ms14932 KiB
#include<bits/stdc++.h> using namespace std ; //it ain't much but it's honest work int n ; set<string>r ; string ans , s ; void ihope( string a , string b){ string c ; //cout << a << ' ' << b << endl ; int ac=0 , bc=0 ; for(int i=0 ; i<n/2 ; i++){ if(a[i]!=b[bc]){ bc++ ; } if(a[i]==b[bc]){ c+=a[i] ; } bc++ ; if(bc>n/2) break ; } //cout << c << endl ; if(c.size()==n/2){ ans=c ; r.insert(ans) ; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n >> s ; if(n%2==0){ cout << "NOT POSSIBLE" ; return 0 ; } string a1 , b1 ; for(int i=0 ; i<n/2 ; i++){ a1+=s[i] ; } for(int i=n/2 ; i<n ; i++){ b1+=s[i] ; } ihope(a1 , b1) ; string a2 , b2 ; for(int i=0 ; i<n/2+1 ; i++){ a2+=s[i] ; } for(int i=n/2+1 ; i<n ; i++){ b2+=s[i] ; } ihope(b2 , a2) ; string a3 , b3 ; for(int i=0 ; i<n/2 ; i++){ a3+=s[i] ; } for(int i=n/2+1 ; i<n ; i++){ b3+=s[i] ; } ihope(a3,b3) ; if(r.size()>1){ cout << "NOT UNIQUE" ; } else if(r.size()==0){ cout << "NOT POSSIBLE" ; } else{ cout << ans ; } }

Compilation message (stderr)

friends.cpp: In function 'void ihope(std::string, std::string)':
friends.cpp:24:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if(c.size()==n/2){
      |        ~~~~~~~~^~~~~
friends.cpp:12:9: warning: unused variable 'ac' [-Wunused-variable]
   12 |     int ac=0 , bc=0 ;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...