제출 #105632

#제출 시각아이디문제언어결과실행 시간메모리
105632pamaj세 명의 친구들 (BOI14_friends)C++14
35 / 100
1075 ms8188 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; if(n%2 == 0) cout << "NOT POSSIBLE\n"; else { int cnt[30]; memset(cnt, 0, sizeof(cnt)); int sz = n/2; for(int i = 0; i < n; i++) { cnt[s[i] - 'A']++; } int lt = -1; for(int i = 0; i < 26; i++) { if(cnt[i]%2) { if(lt == -1) lt = i; else { cout << "NOT POSSIBLE\n"; return 0; } } } //cout << lt << "\n"; if(lt == -1) { cout << "NOT POSSIBLE\n"; return 0; } string temp; bool already = false; for(int i = 0; i < s.size(); i++) { if(s[i] - 'A' == lt) { string tmp; string pass; bool ok = true; for(int j = 0; j < n; j++) { if(j == i) continue; tmp += s[j]; } for(int j = 0; j < sz; j++) { if(tmp[j] == tmp[j + sz]) { pass += tmp[j]; } else ok = false; } if(ok) { if(already) { bool eh = true; for(int i = 0; i < temp.size(); i++) { if(temp[i] != pass[i]) eh = false; } if(!eh) { cout << "NOT UNIQUE\n"; return 0; } } else temp = pass, already = true; } } } if(already) cout << temp << "\n"; else cout << "NOT POSSIBLE\n"; } }

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

friends.cpp: In function 'int main()':
friends.cpp:53:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < s.size(); i++)
                  ~~^~~~~~~~~~
friends.cpp:81:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0; i < temp.size(); i++)
                      ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...