제출 #699921

#제출 시각아이디문제언어결과실행 시간메모리
699921elkernos콤보 (IOI18_combo)C++17
100 / 100
27 ms556 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string guess_sequence(int N) { string s = ""; string maybe = "ABXY"; auto guess_one = [&]() { if (press("AB")) { if (press("A")) s = "A"; else s = "B"; } else { if (press("X")) s = "X"; else s = "Y"; } }; guess_one(); // 2 zap string xdd = ""; for (auto x : maybe) if (x != s[0]) xdd += x; maybe = xdd; while (size(s) < N - 1) { // n - 3 zap string pyt = s + maybe[0] + s + maybe[1] + maybe[0] + s + maybe[1] + maybe[1] + s + maybe[1] + maybe[2]; int odp = press(pyt); if (odp == size(s)) s += maybe[2]; else if (odp == size(s) + 1) s += maybe[0]; else s += maybe[1]; } mt19937 gen(32173); shuffle(maybe.begin(), maybe.end(), gen); if (N == 1) return s; if (press(s + maybe[0]) > size(s)) s += maybe[0]; // 2 zap else if (press(s + maybe[1]) > size(s)) s += maybe[1]; else s += maybe[2]; return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while (size(s) < N - 1) { // n - 3 zap
      |            ~~~~~~~~^~~~~~~
combo.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (odp == size(s)) s += maybe[2];
      |             ~~~~^~~~~~~~~~
combo.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         else if (odp == size(s) + 1) s += maybe[0];
      |                  ~~~~^~~~~~~~~~~~~~
combo.cpp:35:29: 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 (press(s + maybe[0]) > size(s)) s += maybe[0]; // 2 zap
      |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:36:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     else if (press(s + maybe[1]) > size(s)) s += maybe[1];
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...