Submission #743313

#TimeUsernameProblemLanguageResultExecution timeMemory
743313irmuunThree Friends (BOI14_friends)C++17
100 / 100
13 ms7324 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,string t){ int n=s.size(); int cur=0; for(int i=0;i<s.size();i++){ if(cur<n-1&&s[i]==t[cur]){ cur++; } } return (cur==n-1); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; string s; cin>>s; if(n%2==0){ cout<<"NOT POSSIBLE"; return 0; } set<string>st; if(check(s.substr(n/2,n/2+1),s.substr(0,n/2))==true){ st.insert(s.substr(0,n/2)); } if(check(s.substr(0,n/2+1),s.substr(n/2+1,n/2))==true){ st.insert(s.substr(n/2+1,n/2)); } if(st.size()==0){ cout<<"NOT POSSIBLE"; } else if(st.size()==1){ cout<<*st.begin(); } else{ cout<<"NOT UNIQUE"; } }

Compilation message (stderr)

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