제출 #102701

#제출 시각아이디문제언어결과실행 시간메모리
102701bert30702콤보 (IOI18_combo)C++17
100 / 100
50 ms572 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; //int press(string s) { // cout << s << endl; // int k; cin >> k; // return k; //} string guess_sequence(int N) { if(N == 1) { string a = "A"; int A = press(a); string b = "B"; int B = press(b); string x = "X"; int X = press(x); string y = "Y"; if(A == 1) return a; else if(B == 1) return b; else if(X == 1) return x; else return y; } char c[4] = {'A', 'B', 'X', 'Y'}; bool GG[4] = {}; string a = "A"; string b = "B"; string x = "X"; string y = "Y"; int AB = press(a + b); string cur; if(AB >= 1) { int k = press(a); if(k == 1) cur = a, GG[0] = true; else cur = b, GG[1] = true; } else { int k = press(x); if(k == 1) cur = x, GG[2] = true; else cur = y, GG[3] = true; } string OK; for(int j = 0; j < 4; j ++) if(!GG[j]) OK.push_back(c[j]); for(int i = 2; i < N; i ++) { string ask = cur + OK[0] + cur + OK[1] + OK[0] + cur + OK[1] + OK[1] + cur + OK[1] + OK[2]; int k = press(ask); if(k == cur.size() + 0) cur += OK[2]; if(k == cur.size() + 1) cur += OK[0]; if(k == cur.size() + 2) cur += OK[1]; } assert(cur.size() == N - 1); if(press(cur + OK[0]) == N) return cur + OK[0]; if(press(cur + OK[1]) == N) return cur + OK[1]; else return cur + OK[2]; } //int main() { // cout << "! " << guess_sequence(6); //} //// ABXXXY

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   if(k == cur.size() + 0) cur += OK[2];
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp:48:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   if(k == cur.size() + 1) cur += OK[0];
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp:49:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   if(k == cur.size() + 2) cur += OK[1];
      |      ~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:51:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |  assert(cur.size() == N - 1);
      |         ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...