제출 #657157

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6571572022-11-08 23:54:19Juan세 명의 친구들 (BOI14_friends)C++17
100 / 100
128 ms7488 KiB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 5;
char v[maxn];
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++) cin >> v[i];
int ok = 0, diffcnt = 0;
string ans = "", left="", right="";
for(int i = 0; i < n/2; i++) left+=v[i];
for(int i = n/2; i < n-1; i++) right+=v[i];
for(int i = 0; i < n/2; i++) if(left[i]!=right[i]) diffcnt++;
if(!diffcnt) ok++, ans = right;
for(int i = n-2; i >= n/2; i--){
int op;
if(right[i-n/2] == left[i-n/2]) op=-1; else op = -2;
right[i-n/2] = v[i+1];
if(right[i-n/2] == left[i-n/2]) op+=1; else op += 2;
diffcnt+=op;
if(!diffcnt){
ok++;
if(ok>=2 && op) {cout << "NOT UNIQUE\n"; return 0;}
if(ok==1) ans=right;
}
}
for(int i = n/2-1; i >= 0; i--){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...