제출 #44321

#제출 시각아이디문제언어결과실행 시간메모리
44321dhruvsomani세 명의 친구들 (BOI14_friends)C++14
100 / 100
31 ms5692 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; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> s; if (n%2 == 0) { cout << "NOT POSSIBLE"; return 0; } set<string> count; int one, two; bool done, poss; one = 0; two = n/2 + 1; done = false; poss = true; temp = ""; while((two < n) && (temp.size() < n/2)) { if (s[one] != s[two]) { if (!done) { done = true; one++; } else { poss = false; break; } } else { temp += s[one]; one++; two++; } } if (poss) count.insert(temp); one = 0; two = n/2; done = false; poss = true; temp = ""; while((two < n) && (temp.size() < n/2)) { if (s[one] != s[two]) { if (!done) { done = true; two++; } else { poss = false; break; } } else { temp += s[one]; one++; two++; } } if (poss) count.insert(temp); if (count.size() == 0) cout << "NOT POSSIBLE"; else if (count.size() == 1) cout << *(count.begin()); else cout << "NOT UNIQUE"; return 0; }

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

friends.cpp: In function 'int main()':
friends.cpp:48:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while((two < n) && (temp.size() < n/2)) {
                      ~~~~~~~~~~~~^~~~~
friends.cpp:74:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while((two < n) && (temp.size() < n/2)) {
                      ~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...