제출 #419777

#제출 시각아이디문제언어결과실행 시간메모리
419777den_tar세 명의 친구들 (BOI14_friends)C++14
0 / 100
1081 ms4192 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio();cin.tie();cout.tie(); #define en cout<<endl; #define ops cout<<"ops"<<endl; #define line cout<<"---------------------------"<<endl; #define fi first #define se second typedef long long ll; typedef long double ld; typedef pair<ll,ll> pllll; typedef string str; const ll DIM = 2e6 + 7; const ll DIMM = 1e2 + 7; const ll DDIM = 7; const ll INF = 1e18 + 7; const ll X = 1e5 + 7; const ll BS = 2e5 + 7; const ll AS = 26 + 7; const ll MODULO = 1e9 + 7; ll nt,n,m,k,q; ll val,val1; ll c[AS]; ll sz,p1,p2,p3,p4,fl; vector<ll> r; str s,s1,res; int main() { fast; //ll x1,y1,x2,y2; cin>>n>>s; for(int i=0; i<n; i++) { val=s[i]-'A'+1; c[val]++; } val=(-1); for(int i=1; i<=26; i++) { if(c[i]==1)val=i; if(c[i]%2==1)k++; } if(n%2==0) { cout<<"NOT POSSIBLE"<<endl; return 0; } if(k!=1) { cout<<"NOT POSSIBLE"<<endl; return 0; } if(val!=(-1)) { res=""; for(int i=0; i<n/2; i++) { val1=s[i]-'A'+1; if(val!=val1)res+=s[i]; } sz=res.length(); if(sz != (n/2))res+=s[n/2]; cout<<res<<endl; return 0; } res=""; fl=0; for(int j=0;j<n;j++){ if(j<=n/2){ p1=0;p2=n/2+1; } else{ p1=0;p2=n/2; } while(1){ if(p1==j)p1++; if(p2==j)p2++; if(s[p1]!=s[p2] || p2==(n-1))break; p1++; p2++; } if(p2!=(n-1))continue; fl=1; s1=""; for(int i=0;i<n/2;i++){ if(i==j)continue; s1+=s[i]; } sz=s1.length(); if(sz < n/2)s1+=s[n/2]; if(res=="")res=s1; else{ cout<<"NOT UNIQUE"<<endl; return 0; } } if(fl==0){ cout<<"NOT POSSIBLE"<<endl; return 0; } cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...