Submission #295092

#TimeUsernameProblemLanguageResultExecution timeMemory
295092LawlietThree Friends (BOI14_friends)C++17
100 / 100
105 ms8168 KiB
#include <bits/stdc++.h> using namespace std; int n; string s; vector<string> ans; void answer(string t) { cout << t << endl; exit(0); } void test(string a, string b) { int pA = 0, pB = 0; int qtdUnmatches = 0; while( pA < (int)a.size() && pB < (int)b.size() ) { if( a[pA] == b[pB] ) pA++, pB++; else pB++, qtdUnmatches++; } if( qtdUnmatches > 1 ) return; if( ans.empty() || ans.back() != a ) ans.push_back( a ); } int main() { cin >> n >> s; if( n%2 == 0 ) answer( "NOT POSSIBLE" ); n /= 2; test( s.substr( 0 , n ) , s.substr( n , n + 1 ) ); test( s.substr( n + 1 , n ) , s.substr( 0 , n + 1 ) ); if( ans.empty() ) answer( "NOT POSSIBLE" ); if( ans.size() == 1 ) answer( ans.back() ); if( ans.size() == 2 ) answer( "NOT UNIQUE" ); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...