Submission #930623

#TimeUsernameProblemLanguageResultExecution timeMemory
930623yeehawThree Friends (BOI14_friends)C++17
0 / 100
46 ms5340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") int32_t main(){ ios::sync_with_stdio(0);cin.tie(0); int n;cin>>n; char a[n]; for(int i=0;i<n;i++)cin>>a[i]; if(n%2==0){ cout<<"NOT POSSIBLE"; return 0; } int in=n/2,c=0,co=2,s=1,f=1; for(int i=0;i<n/2;i++){ if(a[i]==a[i+in+c]); else{ i--; if(c==1){ f=0; co--; break; }c++; } } in++;c=0; for(int i=0;i<n/2;i++){ if(a[i+c]==a[i+in]); else{ i--; if(c==1){ s=0; co--; break; }c++; } } if(co==2)cout<<"NOT UNIQUE"; else if(co==0)cout<<"NOT POSSIBLE"; else{ if(s){ c=0; for(int i=0;i<n/2;i++){ if(a[i+c]==a[i+n/2+1])cout<<a[i+c]; else {i--;c++;} } }else{ c=0; for(int i=0;i<n/2;i++){ if(a[i]==a[i+n/2+1+c])cout<<a[i]; else {i--;c++;} } } } }

Compilation message (stderr)

friends.cpp: In function 'int32_t main()':
friends.cpp:16:29: warning: variable 'f' set but not used [-Wunused-but-set-variable]
   16 |     int in=n/2,c=0,co=2,s=1,f=1;
      |                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...