Submission #293828

#TimeUsernameProblemLanguageResultExecution timeMemory
293828SaboonCombo (IOI18_combo)C++17
100 / 100
41 ms704 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; map<char,char> mp; string guess_sequence(int n){ string p; if (press("AB") > 0){ if (press("A")) p = "A"; else p = "B"; } else{ if (press("X")) p = "X"; else p = "Y"; } if (n == 1) return p; char fi = p[0]; mp['A'] = 'A', mp['B'] = 'B', mp['X'] = 'X', mp['Y'] = 'Y'; mp[fi] = 'A', mp['A'] = fi; for (int i = 1; i < n-1; i++){ string Tmp = (p + mp['B']) + (p+mp['X']+mp['B']) + (p+mp['X']+mp['X']) + (p+mp['X']+mp['Y']); assert(Tmp.size() <= 4*n); int t = press(Tmp); if (t == i) p += mp['Y']; else if (t == i+1) p += mp['B']; else if (t == i+2) p += mp['X']; else assert(false); } if (press(p+mp['B']) == n) p += mp['B']; else if (press(p+mp['X']) == n) p += mp['X']; else p += mp['Y']; return p; }

Compilation message (stderr)

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:2:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   assert(Tmp.size() <= 4*n);
      |          ~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...