제출 #314134

#제출 시각아이디문제언어결과실행 시간메모리
314134lauran콤보 (IOI18_combo)C++14
100 / 100
47 ms608 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string ret; // 1. aflu primul caracter int ans = press("AB"); if (ans == 0) { ans = press("Y"); if (ans == 1) ret += "Y"; else ret += "X"; } else if (ans == 1) { ans = press("A"); if (ans == 1) ret += "A"; else ret += "B"; } else ret += "A"; vector <string> rest; if (ret[0] != 'A') rest.push_back("A"); if (ret[0] != 'B') rest.push_back("B"); if (ret[0] != 'X') rest.push_back("X"); if (ret[0] != 'Y') rest.push_back("Y"); for (int i = 2; i <= n - 1; i++) { ans = press((ret + rest[0]) + (ret + rest[1] + rest[0]) + ret + (rest[1] + rest[1]) + ret + (rest[1] + rest[2])); if (ans == ret.size() + 1) ret += rest[0]; else if (ans == ret.size() + 2) ret += rest[1]; else if (ans == ret.size()) ret += rest[2]; } if (n > 1) for (int i = 0; i <= 1; i++) { ans = press(ret + rest[i]); if (ans == ret.size() + 1) return ret + rest[i]; } if (n > 1) return ret + rest[2]; return ret; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (ans == ret.size() + 1)
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         else if (ans == ret.size() + 2)
      |                  ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         else if (ans == ret.size())
      |                  ~~~~^~~~~~~~~~~~~
combo.cpp:45:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (ans == ret.size() + 1)
      |             ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...