제출 #1213822

#제출 시각아이디문제언어결과실행 시간메모리
1213822i_love_springThree Friends (BOI14_friends)C++20
100 / 100
13 ms8168 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array bool check(string s,string t) { int j = 0; for (int i = 0; i < s.size() && j < t.size();i++) { if (s[i] == t[j]) j++; } return j == t.size(); } void solve() { int n; cin >> n; string s; cin >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE"; return; } int m = n / 2; string a = s.substr(0,m), b = s.substr(0,m + 1), c = s.substr(m + 1),d = s.substr(m); if (check(d,a)) { if (check(b,c)) { if (a != c) cout << "NOT UNIQUE"; else cout << a; }else cout <<a; }else { if (check(b,c)) { cout << c; }else cout << "NOT POSSIBLE"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; //cin >> t; while (t--) { solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...