Submission #938196

#TimeUsernameProblemLanguageResultExecution timeMemory
938196Sir_Ahmed_ImranThree Friends (BOI14_friends)C++17
100 / 100
27 ms7680 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define append push_back #define add insert #define nl "\n" #define ff first #define ss second #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL) #define N 100001 void solve(){ int n,m,o,p,q,r; string s,t; cin>>n>>s; s.append('.'); if(n%2==0){ cout<<"NOT POSSIBLE"; return; } m=n/2; t=""; for(int i=0;i<m;i++){ if(s[i]!=s[i+m+1]) break; t.append(s[i]); } if(t.size()==m){ cout<<t; return; } o=p=q=0; for(int i=m;i<n;i++) if(s[i]==s[o]) o++; if(o>=m) p=1; o=m+1; for(int i=0;i<=m;i++) if(s[i]==s[o]) o++; if(o>=n) q=1; if(p && q) cout<<"NOT UNIQUE"; else if(p){ for(int i=0;i<m;i++) cout<<s[i]; } else if(q){ for(int i=m+1;i<n;i++) cout<<s[i]; } else cout<<"NOT POSSIBLE"; } int main(){ L0TA; solve(); return 0; }

Compilation message (stderr)

friends.cpp: In function 'void solve()':
friends.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     if(t.size()==m){
      |        ~~~~~~~~^~~
friends.cpp:15:19: warning: unused variable 'r' [-Wunused-variable]
   15 |     int n,m,o,p,q,r;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...