Submission #841971

#TimeUsernameProblemLanguageResultExecution timeMemory
841971manizareThree Friends (BOI14_friends)C++14
100 / 100
18 ms11444 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second #define all(a) a.begin(),a.end() #define pii pair <int,int> #define int long long using namespace std ; mt19937 rng(time(0)) ; const int maxn = 2e6 + 10 , pr[] = {71 , 73}; int sl(string a, string b){ int x = -1 ; for(int i =0 ; i < a.size()-1 ; i++){ if(a[i] != b[i])break ; x++; } int y = a.size() ; for(int i= a.size() - 1; i >= 1; i--){ if(a[i] != b[i-1])break; y--; } if(y-x <= 2){ return 1; } return 0 ; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n ; string s; cin >> n >> s ; if(n % 2==0){ cout << "NOT POSSIBLE\n"; return 0 ; } s = " " + s; string a1 , b1 , a2 ,b2 ; for(int i = 1; i <= n/2 ;i++){ b2 += s[i] ; a1 += s[i] ; } a1 += s[n/2 +1] ; for(int i =n/2+2 ; i <= n; i++){ b1 += s[i] ; a2 += s[i] ; } a2 = s[n/2+1] + a2 ; int x = sl(a1 , b1) , y = sl(a2 , b2); if(x==0 && y == 0){ cout << "NOT POSSIBLE\n"; return 0 ; } if(x==1 && y==1 && b1 != b2){ cout << "NOT UNIQUE\n"; return 0 ; } if(x==1){ cout << b1 << "\n" ; }else{ cout << b2 << "\n" ; } }

Compilation message (stderr)

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