Submission #240577

#TimeUsernameProblemLanguageResultExecution timeMemory
240577GoolakhThree Friends (BOI14_friends)C++17
100 / 100
35 ms7168 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("Os") #define F first #define S second #define pb push_back #define SZ(x) (ll)(x.size()) #define all(x) x.begin(),x.end() //#define mp make_pair typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll maxn=2e6+10, maxm=2e3+10, lg=22, mod=1e9+9, inf=1e18; int n,i,j; string s,t,ans; map<string,bool> mp; int main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; cin>>s; s='#'+s; if(n%2==0) return cout<<"NOT POSSIBLE",0; for(i=1,j=0;i<=n/2;i++) t+=s[i]; for(;i<=n;i++) j+=(s[i]==t[j]); if(j==n/2) mp[ans=t]=1; for(t="",i=(n/2)+2;i<=n;i++) t+=s[i]; for(i=1,j=0;i<=n/2+1;i++) j+=(s[i]==t[j]); if(j==n/2) mp[ans=t]=1; if(mp.empty()) cout<<"NOT POSSIBLE"; else if(SZ(mp)>1) cout<<"NOT UNIQUE"; else cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...