Submission #1007168

#TimeUsernameProblemLanguageResultExecution timeMemory
1007168makanhuliaCombo (IOI18_combo)C++17
5 / 100
1 ms344 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() // int press(string hm) { // cout << hm << endl; // int ans;cin>>ans; // return ans; // } string S = "ABXY"; char getpatokan() { char x = 'O'; for (int j = 0; j < 3; j++) { string r; r += S[j]; if (press(r) == 1) { x = S[j]; break; } } return (x == 'O' ? S[3] : x); } // ABXYBYYXB // patokan: A // BXYBYYXB // guess 2 chars by 2 queries // XX, BX, BY, YB -> 2 // XB, BB, XY, YX -> 1 // XXX // AYY string guess_sequence(int n) { if (n == 0) return ""; char patokan = getpatokan(); set<char> st{'A', 'B', 'X', 'Y'}; st.erase(patokan); string now; now += patokan; vector<char> a(all(st)); // cout << a << endl; for (int i = 0; i < n-2; i++) { // cout << now << endl; string s; for (int j = 0; j < 3; j++) s += now + a[0] + a[j]; s += now + a[1]; int x = press(s); if (x-now.size() == 0) now += a[2]; else if (x - now.size() == 1) now += a[1]; else now += a[0]; } for (auto c : a) { if (press(now + c) == now.size()+1) { return now+c; } } // return now; } // int main() { // int n;cin>>n; // cout << guess_sequence(n) << endl; // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     if (press(now + c) == now.size()+1) {
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:44:34: warning: control reaches end of non-void function [-Wreturn-type]
   44 |   set<char> st{'A', 'B', 'X', 'Y'};
      |                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...