제출 #832497

#제출 시각아이디문제언어결과실행 시간메모리
832497EntityPlantt세 명의 친구들 (BOI14_friends)C++14
100 / 100
41 ms10148 KiB
#include <iostream> using namespace std; int n; bool canFirst, canSecond; string s, t1, t2; bool canAddLetter(const string &t) { bool added = false; for (int i = 0; i < t.size(); i++) { if (!added && t[i] != s[i]) added = true; if (added && t[i] != s[i + 1]) return false; } return true; } int main() { cin >> n >> s; if (n & 1) { n >>= 1; t1 = s.substr(0, n); t2 = s.substr(n + 1); canFirst = canAddLetter(t1 + t1); canSecond = canAddLetter(t2 + t2); if (canFirst && canSecond && t1 == t2) cout << t1; else if (canFirst && canSecond) cout << "NOT UNIQUE"; else if (canFirst) cout << t1; else if (canSecond) cout << t2; else cout << "NOT POSSIBLE"; } else cout << "NOT POSSIBLE"; return 0; }

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

friends.cpp: In function 'bool canAddLetter(const string&)':
friends.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i < t.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...