제출 #349404

#제출 시각아이디문제언어결과실행 시간메모리
349404Rainbowbunny세 명의 친구들 (BOI14_friends)C++17
100 / 100
65 ms9196 KiB
#include <iostream> #include <vector> int n, pt; bool ok1, ok2; std::string s, t1, t2; int main() { std::cin >> n; if(n % 2 == 0) { std::cout << "NOT POSSIBLE"; return 0; } std::cin >> s; for(int i = 0; i < n / 2; i++) { t1.push_back(s[i]); } for(int i = n / 2 + 1; i < n; i++) { t2.push_back(s[i]); } pt = 0; for(int i = n / 2; i < n; i++) { if(pt != t1.size() and s[i] == t1[pt]) { pt++; } } if(pt == t1.size()) { ok1 = true; } pt = 0; for(int i = 0; i <= n / 2; i++) { if(pt != t2.size() and s[i] == t2[pt]) { pt++; } } if(pt == t2.size()) { ok2 = true; } if(ok1 and ok2 and t1 != t2) { std::cout << "NOT UNIQUE"; } else if(ok1) { std::cout << t1; } else if(ok2) { std::cout << t2; } else { std::cout << "NOT POSSIBLE"; } }

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

friends.cpp: In function 'int main()':
friends.cpp:28:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(pt != t1.size() and s[i] == t1[pt])
      |      ~~~^~~~~~~~~~~~
friends.cpp:33:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  if(pt == t1.size())
      |     ~~~^~~~~~~~~~~~
friends.cpp:40:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   if(pt != t2.size() and s[i] == t2[pt])
      |      ~~~^~~~~~~~~~~~
friends.cpp:45:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  if(pt == t2.size())
      |     ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...