Submission #382891

#TimeUsernameProblemLanguageResultExecution timeMemory
382891abilThree Friends (BOI14_friends)C++14
0 / 100
164 ms262148 KiB
#include <bits/stdc++.h> #define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() #define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int inf = (1e9 + 7); string p[N]; main(){ SPEEDUP; int n; cin >> n; string s; cin >> s; if(!(n & 1)){ cout << "NOT POSSIBLE"; return 0; } string a = "", b = ""; for(int j = n / 2 + 1; j < n; j++){ b.pb(s[j]); } for(int i = n / 2; i >= 0; i--){ p[i] = a; a = s[i] + a; } a = ""; vector<string > ans; for(int i = 0;i <= n / 2; i++){ if(a + p[i] == b){ ans.pb(b); } a.pb(s[i]); } b = ""; a = ""; for(int i = 0;i < n / 2; i++){ a.pb(s[i]); } for(int i = n / 2; i < n; i++){ p[i] = b; b.pb(s[i]); } b = ""; for(int i = n / 2; i < n; i++){ if(b + p[i] == a){ ans.pb(a); } b.pb(s[i]); } if(ans.size() > 1){ cout << "NOT UNIQUE"; return 0; } if(ans.empty()){ cout << "NOT POSSIBLE"; return 0; } cout << ans[0]; }

Compilation message (stderr)

friends.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...