제출 #743287

#제출 시각아이디문제언어결과실행 시간메모리
743287irmuun세 명의 친구들 (BOI14_friends)C++17
0 / 100
1067 ms10520 KiB
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

bool check(string s){
    if(s.size()%2==1){
        return false;
    }
    int n=s.size();
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[i+n/2]){
            return false;
        }
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>cnt(26);
    int ans=0;
    string x;
    for(int i=0;i<n;i++){
        string t=s.substr(0,i)+s.substr(i+1,n-i-1);
        if(check(t)==true){
            x=t;
            ans++;
        }
    }
    if(ans==0){
        cout<<"NOT POSSIBLE";
    }
    else if(ans==1){
        cout<<x.substr(0,n/2);
    }
    else{
        cout<<"NOT UNIQUE";
    }
}

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

friends.cpp: In function 'bool check(std::string)':
friends.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<s.size()/2;i++){
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...