제출 #824785

#제출 시각아이디문제언어결과실행 시간메모리
824785QwertyPi세 명의 친구들 (BOI14_friends)C++14
100 / 100
42 ms6432 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 2e6 + 11; bool check(const string& s, const string& t){ int si = 0; for(auto c : t){ while(si < s.size() && s[si] != c){ si++; } if(si >= s.size() || s[si] != c) return false; si++; } for(auto c : t){ while(si < s.size() && s[si] != c){ si++; } if(si >= s.size() || s[si] != c) return false; si++; } return true; } int32_t main() { int n; cin >> n; string s; cin >> s; if(n % 2 == 0){ cout << "NOT POSSIBLE" << endl; return 0; } string t1 = s.substr(0, n / 2); string t2 = s.substr(n / 2 + 1); bool ok1 = check(s, t1); bool ok2 = check(s, t2); if(ok1 && ok2 && t1 != t2){ cout << "NOT UNIQUE" << endl; }else if(ok1){ cout << t1 << endl; }else if(ok2){ cout << t2 << endl; }else{ cout << "NOT POSSIBLE" << endl; } }

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

friends.cpp: In function 'bool check(const string&, const string&)':
friends.cpp:10:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   while(si < s.size() && s[si] != c){
      |         ~~~^~~~~~~~~~
friends.cpp:13:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   if(si >= s.size() || s[si] != c) return false;
      |      ~~~^~~~~~~~~~~
friends.cpp:17:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   while(si < s.size() && s[si] != c){
      |         ~~~^~~~~~~~~~
friends.cpp:20:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if(si >= s.size() || s[si] != c) return false;
      |      ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...