Submission #72881

#TimeUsernameProblemLanguageResultExecution timeMemory
72881VardanyanThree Friends (BOI14_friends)C++14
0 / 100
1049 ms32312 KiB
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    rope<char> v;
    int c = 0;
    for(int i = 0;i<s.length();i++){
        v.push_back(s[i]);
    }
    rope<char> ans;
    for(int i = 0;i<n;i++){
        char x = v[i];
        v.erase(v.mutable_begin()+i);
        rope<char> w = v.substr(0,n/2);
        rope<char> e = v.substr(n/2,n-2);
        if(w == e){
                c++;
                ans = w;
        }
        v.insert(v.mutable_begin()+i,x);
    }
    if(c == 0){
        cout<<"NOT POSSIBLE"<<endl;
        return 0;
    }
    if(c == 1){
        for(int i = 0;i<ans.size();i++) cout<<ans[i];
        cout<<endl;
        return 0;
    }
    cout<<"NOT UNIQE"<<endl;
    return 0;
}

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<s.length();i++){
                   ~^~~~~~~~~~~
friends.cpp:33:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i<ans.size();i++) cout<<ans[i];
                       ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...