Submission #938115

#TimeUsernameProblemLanguageResultExecution timeMemory
938115PagodePaivaCombo (IOI18_combo)C++17
94 / 100
24 ms1832 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { // int coins = press(p); string s = ""; int n = N; char f = '0'; vector <char> c = {'A', 'B', 'X', 'Y'}; for(int i = 0 ;i < 3;i++){ s.push_back(c[i]); int x = press(s); if(x == 1){ f = c[i]; break; } s.pop_back(); } if(f == '0') { f = 'Y'; s.push_back(f); } vector <char> cr; for(auto x : c){ if(x == f) continue; cr.push_back(x); } for(int i = 1;i <= n-3;i++){ string a, b, c, d; a = b = c = d = s; a.push_back(cr[0]); a.push_back(f); b.push_back(cr[1]); b.push_back(cr[0]); b.push_back(f); c.push_back(cr[1]); c.push_back(cr[1]); c.push_back(f); d.push_back(cr[1]); d.push_back(cr[2]); string res; res = a; for(auto x : b) res.push_back(x); for(auto x : c) res.push_back(x); for(auto x : d) res.push_back(x); // cout << res << endl; int resp = press(res); if(resp == i) s.push_back(cr[2]); else if(resp == i+1) s.push_back(cr[0]); else s.push_back(cr[1]); } for(int i = max(n-2, 1);i < n;i++){ string aux = s; aux.push_back(cr[0]); int resp = press(aux); if(resp == i+1) s = aux; else{ aux.pop_back(); aux.push_back(cr[1]); resp = press(aux); if(resp == i+1) s = aux; else s.push_back(cr[2]); } } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...