제출 #1156738

#제출 시각아이디문제언어결과실행 시간메모리
1156738arsen23세 명의 친구들 (BOI14_friends)C++20
0 / 100
16 ms6164 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define pb push_back #define F first #define S second #define in insert using namespace std; typedef long long ll; typedef unsigned long long ull; const int N = 1e6 + 123; const int P = 320; const int mod = 1e9 + 7; ll n, m, k, q; string s; void salemkhan() { cin >> n >> s; if(n % 2 == 0) { cout << "NOT POSSIBLE"; return; } string cur1 = ""; string cur2 = ""; for(int i = 0; i < n / 2; i++) { cur1 += s[i]; } for(int i = n / 2 + 1; i < n; i++) { cur2 += s[i]; } bool f1, f2; f1 = f2 = 0; ll l = 0; for(int i = n / 2; i < n; i++) { if(cur1[l] == s[i]) { l++; } } if(l == n / 2) { f1 = 1; } l = 0; for(int i = 0; i <= n / 2; i++) { if(cur2[l] == s[i]) l++; } if(l == n / 2) { f2 = 1; } if(f1 && f2) { cout << "NOT UNIQUE"; } else if(f1 && !f2) { cout << cur1; } else if(f2 && !f1) { cout << cur2; } else cout << "NOT POSSIBLE"; } // 28 37 48 49 55 56 57 58 67 9 // 9 + 1 + int main() { //freopen("knight.in", "r", stdin); //freopen("knight.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll tt = 1; //cin >> tt; while(tt--) { salemkhan(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...