Submission #250999

#TimeUsernameProblemLanguageResultExecution timeMemory
250999WhaleVomitThree Friends (BOI14_friends)C++14
100 / 100
18 ms9252 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define sz(v) (int)v.size() #define MOO(i, a, b) for(int i=a; i<b; i++) #define M00(i, a) for(int i=0; i<a; i++) #define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--) #define M00d(i,a) for(int i = (a)-1; i>=0; i--) #define FAST ios::sync_with_stdio(0); cin.tie(0); #define finish(x) return cout << x << '\n', 0; #define dbg(x) cerr << ">>> " << #x << " = " << x << "\n"; #define _ << " _ " << template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;} template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;} typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef pair<ld,ld> pd; typedef complex<ld> cd; int n; string s; bool good(string s1, string s2) { int idx = 0; bool diff = 0; M00(i, sz(s2)) { if(idx >= sz(s1) || s2[i] != s1[idx]) { if(diff) return 0; else diff = 1; } else { idx++; } } if(idx != sz(s1)) diff = 0; //dbg(s1 _ s2 _ diff); return diff; } int main() { FAST cin >> n >> s; if(n%2 == 0) { finish("NOT POSSIBLE"); } int k = n/2; string s1 = s.substr(0, k); set<string> res; if(good(s1, s.substr(k, k+1))) { res.insert(s1); } string s2 = s.substr(k+1, k); if(good(s2, s.substr(0, k+1))) { res.insert(s2); } if(sz(res) == 0) { finish("NOT POSSIBLE"); } else if(sz(res) == 2) { finish("NOT UNIQUE"); } else { finish(*res.begin()); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...