Submission #788606

#TimeUsernameProblemLanguageResultExecution timeMemory
788606aykhn콤보 (IOI18_combo)C++14
30 / 100
24 ms452 KiB
#include <bits/stdc++.h> #include "combo.h" // author: aykhn using namespace std; typedef long long ll; #define TC int t; cin >> t; while (t--) _(); #define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(v) v.begin(), v.end() #define pii pair<int, int> #define mpr make_pair #define eb emplace_back #define new int32_t #define pb push_back #define ts to_string #define fi first #define se second //#define int ll #define ins insert #define inf 0x3F3F3F3F #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount string guess_sequence(int n) { srand(time(0)); string ans = "A"; vector<int> ch; ch.pb('A'); ch.pb('B'); ch.pb('X'); ch.pb('Y'); int found = 0; int id = 0; int counnnnt = 0; for (int i = rand() % 4; counnnnt < 3; i = (i + 1) % 4, counnnnt++) { ans[0] = ch[i]; id = i; found = press(ans); if (found) break; } if (!found) { ans[0] = ch[(id + 1) % 4]; id = (id + 1) % 4; } if (n == 1) return ans; counnnnt = 0; found = 0; for (int i = rand() % 4; counnnnt < 2; i = (i + 1) % 4, counnnnt++) { if (ch[i] == ans[0]) { counnnnt--; continue; } string nw = ans; nw.pb(ch[i]); id = i; found = press(nw); if (found == 2) break; } if (found < 2) { id = (id + 1) % 4; if (ch[id] == ans[0]) id = (id + 1) % 4; } if (n == 2) { ans.pb(ch[id]); return ans; } vector<int> tmp; for (int i = 0; i < 4; i++) { if (ch[i] == ans[0]) continue; tmp.pb(ch[i]); if (i == id) { id = tmp.size(); id--; id = -id; } } id = -id; ch = tmp; char add, nxt; add = ch[id]; nxt = ch[(id + 1) % 3]; int prev = 1; while (ans.length() != n) { string nw = ans; nw.pb(add); nw.pb(nxt); int x = press(nw); if (x - prev == 1) { ans.pb(add); prev = x; } else if (x - prev == 2) { ans.pb(add); ans.pb(nxt); id = (id + 1) % 3; add = ch[id]; nxt = ch[(id + 1) % 3]; prev = x; } else { id = (id + 2) % 3; add = ch[id]; nxt = ch[(id + 1) % 3]; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:107:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  107 |     while (ans.length() != n)
      |            ~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...