답안 #943336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943336 2024-03-11T11:00:53 Z Darren0724 세 명의 친구들 (BOI14_friends) C++17
0 / 100
11 ms 8372 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e9;
string cmp(string a,string b){
    if(a.size()>b.size())swap(a,b);
    int bad=0;
    int j=0;
    int n=a.size();
    for(int i=0;i<n;i++){
        while(j<b.size()&&a[i]!=b[j]){
            bad++;
            j++;
        }
        j++;
    }
    return (bad<=1?a:"");
}
int32_t main() {
    LCBorz;
    int n;cin>>n;
    string s;cin>>s;
    string a=cmp(s.substr(0,n/2),s.substr(n/2,n-n/2));
    string b=cmp(s.substr(0,n/2+1),s.substr(n/2+1,n-n/2));
    if(n%2==0||(a.size()==0&&b.size()==0)){
        cout<<"NOT POSSIBLE"<<endl;
        return 0;
    }
    if(a.size()!=0&&b.size()!=0){
        cout<<"NOT UNIQUE"<<endl;
        return 0;
    }
    cout<<(a.size()?a:b)<<endl;


    return 0;
}

Compilation message

friends.cpp: In function 'std::string cmp(std::string, std::string)':
friends.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         while(j<b.size()&&a[i]!=b[j]){
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8108 KB Output is correct
2 Correct 8 ms 8148 KB Output is correct
3 Correct 10 ms 8140 KB Output is correct
4 Correct 9 ms 8372 KB Output is correct
5 Correct 9 ms 8152 KB Output is correct
6 Correct 8 ms 8136 KB Output is correct
7 Incorrect 9 ms 8252 KB Output isn't correct
8 Halted 0 ms 0 KB -