Submission #713755

#TimeUsernameProblemLanguageResultExecution timeMemory
713755becaidoCombo (IOI18_combo)C++17
100 / 100
39 ms568 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #include "combo.h" using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second // times : N+2 string code[] = {"A", "B", "X", "Y"}; string guess_sequence(int N) { string cur; auto ask_one = [&]() { int len; len = press(cur + code[0] + cur + code[1]); if (len > cur.size()) { len = press(cur + code[0]); return len > cur.size() ? code[0] : code[1]; } else { len = press(cur + code[2]); return len > cur.size() ? code[2] : code[3]; } }; cur = ask_one(); for (int i = 0; i < 4; i++) if (code[i][0] == cur[0]) swap(code[0], code[i]); for (int i = 2; i < N; i++) { string ask = cur + code[1] + code[1] + cur + code[1] + code[2] + cur + code[1] + code[3] + cur + code[2]; int len = press(ask); if (len == cur.size() + 2) cur += code[1]; else if (len == cur.size() + 1) cur += code[2]; else cur += code[3]; } if (N > 1) cur += ask_one(); return cur; }

Compilation message (stderr)

combo.cpp: In lambda function:
combo.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (len > cur.size()) {
      |             ~~~~^~~~~~~~~~~~
combo.cpp:31:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             return len > cur.size() ? code[0] : code[1];
      |                    ~~~~^~~~~~~~~~~~
combo.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             return len > cur.size() ? code[2] : code[3];
      |                    ~~~~^~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if (len == cur.size() + 2) cur += code[1];
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         else if (len == cur.size() + 1) cur += code[2];
      |                  ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...