# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1279252 | Iwantbemaster | 콤보 (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <combo.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define tobit(n) bitset<(int)30>(n)
typedef unsigned long long ull;
#define all(v) (v).begin(), (v).end()
#pragma GCC optimize("Ofast","inline","-ffast-math")
#define rtt(v) rotate(vec.begin(), vec.begin() + k, vec.end()); //move k elements back
vector<int> dx = {1, -1, 0, 0, 1, 1, -1, -1}, dy = {0, 0, 1, -1, 1, -1, 1, -1};
vector<pair<int, int>> DX = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const vector<pair<int, int>> ANS = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int MOD = 1e9 + 7, N = (int)1e6, inf = numeric_limits<int>::max();
template <typename T>
extern int press(string p);
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void IO(string str_ = ""){
if((int)str_.size()){
freopen((str_ + ".in").c_str(), "r", stdin);
freopen((str_ + ".out").c_str(), "w", stdout);
}
}
//signed main(){ // clock_t the_time = clock(); double t_;
// IO(""); int n, result = 0; cin >> n;
// vector<int > a(n), b(n), c(n);
// for(auto &to : a) cin >> to;
// for(auto &to : b) cin >> to;
// for (int i = 0; i < n; i++) c[i] = a[i] - b[i];
// sort(c.begin(), c.end());
// auto UPPB = [&](long long x) -> int {
// int l = 0, r = n;
// while(l < r){
// int m = (l + r) / 2;
// if(c[m] <= x) l = m + 1;
// else r = m;
// } return l;
// }; for(int i = 0; i < n; i++){
// result += n - UPPB(-c[i]);
// if(UPPB(-c[i]) <= i) result--;
// } cout << result / 2;
// // t_ = double(clock() - the_time) / CLOCKS_PER_SEC; cout << fixed << setprecision(16)<< t_ << " sec.";
//}
string guess_sequence(int N) {
string s; vector<char> res_;
if(press("AB") > 0){
if(press("A") > 0) s = "A";
else s = "B";
} else {
if(press("X") > 0) s = "X";
else s = "Y";
} if(N == 1){ return s; }
for(char c : {'A', 'B', 'X', 'Y'}) {
if(c != s[0]) res_.emplace_back(c);
} for(int i = 1; i < N - 1; i++){
string str = s + res_[0] + s + res_[1] + res_[0] + s + res_[1] + res_[1] + s + res_[2];
int res = press(str);
if(res == i) s += res_[2];
else if(res == i + 1) s += res_[0];
else s += res_[1];
} if(press(s + res_[0]) == N) s += res_[0];
else if(press(s + res_[1]) == N) s += res_[1];
else s += res_[2];
return s;
}
const int fastIO = [](){
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
return 0;
}();
/*
Открыть терминал: F5
Закрыть терминал: F6
Спрятать/показать терминал: F7
Скомпилировать и запустить: F9
Только запустить: F12
*/