제출 #105694

#제출 시각아이디문제언어결과실행 시간메모리
105694sams세 명의 친구들 (BOI14_friends)C++14
100 / 100
204 ms9312 KiB
#include <bits/stdc++.h> using namespace std; int n; string u; map<char, int> ct; int main() { cin >> n >> u; if(n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } for(auto x: u) ct[x]++; int I = 0; char rep = '.'; for(auto x: ct) if(x.second % 2) I++, rep = x.first; if(I > 1) { cout << "NOT POSSIBLE\n"; return 0; } int mid = (n-1)/2; string s1, s2; int ok = 2; int id = -1; for(int i = 0 ; i < mid ; ++i) s1.push_back(u[i]); for(int i = mid ; i < n ; ++i) s2.push_back(u[i]); string ss = ""; for(int i = 0, j = 0, k = 0; i < mid ; ++j, ++i) { if(s1[i] != s2[j]) { if(k == 0 && s1[i] == s2[j+1]) id = j, j++, k = 1; else { ok--; id = -1; ss = ""; break; } } ss+=s1[i]; } s1.clear(); s2.clear(); for(int i = 0 ; i <= mid ; ++i) s2.push_back(u[i]); for(int i = mid + 1 ; i < n ; ++i) s1.push_back(u[i]); string SS = ""; /* for(int i = 0 ; i < s2.size() ; ++i) cout << s2[i]; cout << "\n"; for(int i = 0 ; i < s1.size() ; ++i) cout << s1[i]; */ for(int i = 0, j = 0, k = 0; i < mid ; ++j, ++i) { if(s1[i] != s2[j]) { if(k == 0 && s1[i] == s2[j+1]) id = j, j++, k = 1; else { ok--; id = -1; SS = ""; break; } } SS+=s1[i]; } if(ok == 0) cout << "NOT POSSIBLE\n"; else if(ok == 1 || ct[rep] == n || ss == SS) { if(ss == "") cout << SS << "\n"; else cout << ss << "\n"; }else cout << "NOT UNIQUE\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'int main()':
friends.cpp:38:6: warning: variable 'id' set but not used [-Wunused-but-set-variable]
  int id = -1;
      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...