제출 #444945

#제출 시각아이디문제언어결과실행 시간메모리
444945Killer2501세 명의 친구들 (BOI14_friends)C++14
100 / 100
36 ms8396 KiB
#include<bits/stdc++.h> #define pll pair<ll, ll> #define fi first #define se second #define pb push_back #define pii pair<ll, pll> using namespace std; using ll = long long; const int N = 1e4+55; const ll mod = 998244353; const ll base = 350; const ll cs = 331; ll m, n, t, k, a[N], ans, tong, b[N], c[N], d[N]; string s, p, q, res; vector<ll> adj[N], kq; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; if(n % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } int pos = 0; while(pos < n/2 && s[pos] == s[pos+n/2])++pos; for(int i = 0; i < n/2; i ++)p += s[i]; for(int i = n/2; i < n; i ++)if(i != pos+n/2)q += s[i]; //cout << p <<" "<<q<<'\n'; if(p == q)res = p; p.clear(); q.clear(); pos = n/2+1; while(pos < n && s[pos] == s[pos-n/2-1])++pos; for(int i = n/2+1; i < n; i ++)q += s[i]; for(int i = 0; i <= n/2; i ++)if(i != pos-n/2-1)p += s[i]; if(p == q) { if(res.size() == 0)cout << p; else if(res != p)cout << "NOT UNIQUE"; else cout << p; return 0; } if(res.size() == 0)cout << "NOT POSSIBLE"; else cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...