제출 #975284

#제출 시각아이디문제언어결과실행 시간메모리
975284ShaShi콤보 (IOI18_combo)C++17
100 / 100
14 ms2020 KiB
#include "combo.h" #include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define all(x) x.begin(), x.end() #define mp make_pair #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int MAX = (int)2e3 + 7; const int MOD = 998244353; const int INF = (int)1e9 + 7; string guess_sequence(int N) { string res, s, op; res = ""; int x = press("AB"); if (x) { x = press("A"); if (x) res.pb('A'); else res.pb('B'); } else { x = press("X"); if (x) res.pb('X'); else res.pb('Y'); } if (N == 1) return res; s = ""; if (res != "A") s += "A"; if (res != "B") s += "B"; if (res != "X") s += "X"; if (res != "Y") s += "Y"; while (res.size() < N-1) { op = ""; op += res; op.pb(s[0]); op += res; op.pb(s[1]); op.pb(s[0]); op += res; op.pb(s[1]); op.pb(s[1]); op += res; op.pb(s[1]); op.pb(s[2]); x = press(op); if (x == res.size()) { res.pb(s[2]); } else if (x == res.size()+1) { res.pb(s[0]); } else if (x == res.size()+2) { res.pb(s[1]); } else { exit(0); } } res.pb(s[0]); x = press(res); if (x == N) return res; res.pop_back(); res.pb(s[1]); x = press(res); if (x == N) return res; res.pop_back(); res.pb(s[2]); return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |  while (res.size() < N-1) {
      |         ~~~~~~~~~~~^~~~~
combo.cpp:63:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   if (x == res.size()) {
      |       ~~^~~~~~~~~~~~~
combo.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   } else if (x == res.size()+1) {
      |              ~~^~~~~~~~~~~~~~~
combo.cpp:67:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   } else if (x == res.size()+2) {
      |              ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...