제출 #1126697

#제출 시각아이디문제언어결과실행 시간메모리
1126697KasymK세 명의 친구들 (BOI14_friends)C++20
100 / 100
36 ms5296 KiB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    scanf("%d", &n);
    string s;
    cin>>s;
    if(n%2==0){
        puts("NOT POSSIBLE");
        return 0;
    }
    n /= 2;
    int gos = 0;
    for(int i = n; i <= 2*n and gos<n; ++i)
        if(s[i]==s[gos])
            gos++;
    bool l = gos==n;
    gos = 0;
    for(int i = 0; i <= n and gos<n; ++i)
    	if(s[i]==s[n+1+gos])
    		gos++;
    bool r = gos==n;
    if(!l and !r)
    	puts("NOT POSSIBLE");
    else if(l and r and s.substr(0, n)!=s.substr(n+1, n))
    	puts("NOT UNIQUE");
    else{
    	if(l)
    		cout<<s.substr(0, n)<<"\n";
    	else
    		cout<<s.substr(n+1, n)<<"\n";
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'int main()':
friends.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...