This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(998244353)
#include "combo.h"
using namespace std;
template<class T1, class T2>
bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2>
bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2>
void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}
template<class T1, class T2>
void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}
template<class T>
void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
//int press(string p){
// cout << p << endl;
// int n; cin >> n;
// return n;
//}
string guess_sequence(int N){
const char buttons[] = {'A', 'B', 'X', 'Y'};
string cur = "";
int p = press("AB");
if(p){
if(press("A")) cur.push_back('A');
else cur.push_back('B');
}
else{
if(press("X")) cur.push_back('X');
else cur.push_back('Y');
}
vector<char> buttonsLeft;
for(int i = 0; i < 4; i++) if(cur[0] != buttons[i]){
buttonsLeft.push_back(buttons[i]);
}
// for(int i = 2; i <= N; i++){
// for(int j = 0; j < 2; j++){
// if(press(cur + buttonsLeft[j]) == i){
// cur.push_back(buttonsLeft[j]);
// break;
// }
// }
// if((int)cur.size() < i) cur.push_back(buttonsLeft.back());
// }
for(int i = 2; i < N; i++){
string s = cur + buttonsLeft[2] + buttonsLeft[0] + cur + buttonsLeft[2] + buttonsLeft[1] + cur + buttonsLeft[2] + buttonsLeft[2] + cur + buttonsLeft[1];
int coins = press(s);
if(coins > i) cur.push_back(buttonsLeft[2]);
else if(coins == i) cur.push_back(buttonsLeft[1]);
else cur.push_back(buttonsLeft[0]);
}
if(N > 1)
if(press(cur + buttonsLeft[0]) == N) cur.push_back(buttonsLeft[0]);
else if(press(cur + buttonsLeft[1]) == N) cur.push_back(buttonsLeft[1]);
else cur.push_back(buttonsLeft[2]);
return cur;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:74:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
74 | if(N > 1)
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |