제출 #422183

#제출 시각아이디문제언어결과실행 시간메모리
422183Tangent콤보 (IOI18_combo)C++17
100 / 100
38 ms564 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; #define ffor(i, a, b) for (ll i = a; i < b; i++) #define rep(i, n) ffor(i, 0, n) #define forin(x, a) for (auto &x: a) #define all(a) a.begin(), a.end() std::string guess_sequence(int N) { if (N == 1) { if (press("AB")) { if (press("A")) { return "A"; } else { return "B"; } } else { if (press("X")) { return "X"; } else { return "Y"; } } } string res, rem; if (press("AB")) { if (press("A")) { res = "A"; rem = "BXY"; } else { res = "B"; rem = "AXY"; } } else { if (press("X")) { res = "X"; rem = "ABY"; } else { res = "Y"; rem = "ABX"; } } while (res.size() < N - 1) { int ans = press(res + rem[0] + res + rem[1] + rem[0] + res + rem[1] + rem[1] + res + rem[1] + rem[2]); if (ans == res.size()) { res += rem[2]; } else if (ans == res.size() + 1) { res += rem[0]; } else { res += rem[1]; } } if (press(res + rem[0]) == N) { return res + rem[0]; } if (press(res + rem[1]) == N) { return res + rem[1]; } return res + rem[2]; }

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

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