# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27460 | TAMREF | 세 명의 친구들 (BOI14_friends) | C++11 | 6 ms | 3988 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mx=2e6+10;
char S[mx];
int N,h;
void input(){
scanf("%d\n",&N);
fgets(S,mx-4,stdin);
S[N]=0;
if(!(N&1)) exit(0&puts("NOT POSSIBLE"));
h=(N-1)>>1;
}
void solve_small(){
char F[2500]={},G[2500]={};
for(int i=0;i<N;i++){
strncpy(F,S,i);
strncpy(F+i,S+i+1,N-1-i);
if(!strncmp(F,F+h,h)){
if(G[0]) exit(0&puts("NOT UNIQUE"));
strncpy(G,F,N-1);
}
}
if(!G[0]) exit(0&puts("NOT POSSIBLE"));
for(int i=0;i<h;i++) putchar(G[i]); puts("");
}
void solve(){
int s=0,e=N-1,xs=-1,xe=-1;
for(int i=0;i<h;i++){
if(S[i]!=S[i+h]){
s=max(s,i);
e=min(e,i+h);
if(s>e) exit(0&puts("NOT POSSIBLE"));
}
if(S[i]!=S[i+h+1]){
if(xs==-1){
xs=i+1;
xe=i+h;
} else{
xs=min(xs,i+1);
xe=max(xe,i+h);
}
}
}
}
int main(){
input();
if(N<2000) solve_small();
else solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |