제출 #44301

#제출 시각아이디문제언어결과실행 시간메모리
44301dhruvsomani세 명의 친구들 (BOI14_friends)C++14
35 / 100
1082 ms2972 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <cmath> #include <string> #include <algorithm> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; int n; string s, temp; map<char, int> dict; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> s; set<string> count; for (int i = 0; i < n; i++) dict[s[i]]++; for (int i = 0; i < n; i++) { int one, two; if (dict[s[i]] % 2 == 0) continue; if (i == 0) { one = 1; two = n/2+1; } else if (i <= n/2) { one = 0; two = n/2 + 1; } else { one = 0; two = n/2; } //cout << "i: " << i << " one: " << one << " two: " << two << endl; bool poss = true; temp = ""; for (int j = 0; j < n/2; j++) { if (s[one] != s[two]) { poss = false; break; } temp += s[one]; one++; two++; if (one == i) one++; if (two == i) two++; } if (poss) count.insert(temp); } if (count.size() == 0) cout << "NOT POSSIBLE\n"; else if (count.size() == 1) cout << *(count.begin()) << endl; else cout << "NOT UNIQUE\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...