이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;
const int maxN = 2000001;
int N; string s;
bool solve( string a, string b ){
// cout << a << " " << b << endl;
int i=0, j=0;
bool flag = true;
while( i < a.length() && j < b.length() ){
if( a[i] == b[j] ){ i++; j++; }
else if( flag ){
flag = false; i++;
}else return false;
}
return true;
}
int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
while( cin >> N >> s ){
if( !( N & 1 ) ){ cout << "NOT POSSIBLE" << endl; continue; }
string S, X;
bool resA, resB;
S = s.substr( 0, N/2 ); X = s.substr( N/2, N );
resA = solve( X, S );
S = s.substr( 0, N/2+1 ); X = s.substr( N/2+1, N );
resB = solve( S, X );
if( resA && resB ){
if( s.substr( 0, N/2 ) == s.substr( N/2+1, N ) ) resB = false;
}
if( resA && resB ) cout << "NOT UNIQUE" << endl;
else if( resA ) cout << s.substr( 0, N/2 ) << endl;
else if( resB ) cout << s.substr( N/2+1, N ) << endl;
else cout << "NOT POSSIBLE" << endl;
break;}
}
컴파일 시 표준 에러 (stderr) 메시지
friends.cpp: In function 'bool solve(std::__cxx11::string, std::__cxx11::string)':
friends.cpp:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( i < a.length() && j < b.length() ){
~~^~~~~~~~~~~~
friends.cpp:17:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( i < a.length() && j < b.length() ){
~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |