Submission #1147329

#TimeUsernameProblemLanguageResultExecution timeMemory
1147329minh30082008Combo (IOI18_combo)C++20
100 / 100
7 ms488 KiB
#include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include "combo.h" #include<bits/stdc++.h> #define INF 1e18 #define fi first #define se second #define FOR(i, k, n) for(ll i = k; i <= n; i++) #define FOR1(i, k, n) for(ll i = k; i >= n; i--) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vi vector<int> #define pii pair<int, int> #define vii vector<pii> #define ll long long #define vll vector<ll> #define pll pair<ll, ll> #define re return 0 #define mii map<int, int> #define input "chinaflu.inp" #define output "chinaflu.out" #define rf freopen(input, "r", stdin); freopen(output, "w", stdout) using namespace std; const int maxn = 3e5 + 5; const int mod = 1e9 + 9; const int base = 998244353; void add(int &a, int b) { a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; } mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return uniform_int_distribution<int>(l, r) (rd); } string guess_sequence(int n) { string P = ""; int k = press("AB"); if(k) { k = press("A"); if(k) P += 'A'; else P += 'B'; } else { k = press("X"); if(k) P += 'X'; else P += 'Y'; } n--; vector<char> vv; vv.clear(); if('A' != P[0]) vv.pb('A'); if('B' != P[0]) vv.pb('B'); if('X' != P[0]) vv.pb('X'); if('Y' != P[0]) vv.pb('Y'); while(true) { if(!n) return P; if(n == 1) { string ask = P; ask += vv[0]; k = press(ask); if(k > (int)P.size()) { P += vv[0]; return P; } ask = P; ask += vv[1]; k = press(ask); if(k == (int)P.size() + 1) { P += vv[1]; return P; } P += vv[2]; return P; } string ask = ""; ask += P; ask += vv[0]; ask += vv[1]; ask += P; ask += vv[0]; ask += vv[0]; ask += P; ask += vv[0]; ask += vv[2]; ask += P; ask += vv[1]; k = press(ask); int cnt = P.size(); if(k == cnt + 2) P += vv[0]; if(k == cnt + 1) P += vv[1]; if(k == cnt) P += vv[2]; n--; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...