제출 #947108

#제출 시각아이디문제언어결과실행 시간메모리
947108steveonalex콤보 (IOI18_combo)C++14
30 / 100
23 ms1460 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1ULL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ll mask){return __builtin_ctzll(mask);} int logOf(ll mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} 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 T> void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } // namespace Interactor{ // int n; // string a; // int query_cnt; // int press(string p){ // query_cnt++; // int ans = 0; // for(int i= 0; i<p.size(); ++i){ // int cnt = 0; // for(int j = 0; i + j < p.size() && j < a.size(); ++j){ // if (p[i+j] == a[j])cnt++; // else break; // maximize(ans, cnt); // } // } // // cout << "? " << p << "\n"; // // cout << "-> " << ans << "\n"; // return ans; // } char pool[] = {'A', 'B', 'X', 'Y'}; string guess_sequence(int n){ int l = 0, r = 3; while(l < r){ int mid = (l + r) >> 1; string p; for(int i = 0; i<=mid; ++i) p.push_back(pool[i]); if (press(p) >= 1) r = mid; else l = mid + 1; } string ans = string(1, pool[l]); vector<int> hot; for(int i= 0; i<4; ++i) if (i != l) hot.push_back(i); for(int i = 2; i<=n; ++i){ for(int j: hot) { if (j == hot.back()){ ans.push_back(pool[j]); break; } if (press(ans + string(1, pool[j])) == i){ ans.push_back(pool[j]); break; } } } return ans; } // bool solve(int _n, string _a){ // query_cnt = 0; // n = _n; a = _a; // string b = guess_sequence(n); // cout << "? " << a << "\n"; // cout << "! " << b << "\n"; // return a == b; // } // } // char pool[] = {'A', 'B', 'X', 'Y'}; // int main(void){ // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int n; cin >> n; // int t = 100; // while(t--){ // string a; // int s = rngesus(0, 3); // a.push_back(pool[s]); // vector<int> hot; // for(int i = 0; i<4; ++i) if (i != s) hot.push_back(i); // for(int i = 1; i<n; ++i) a.push_back(pool[hot[rngesus(0, 2)]] ); // bool verdict = Interactor::solve(n, a); // if (verdict) cout << "AC\n"; // else cout << "WA\n"; // if (verdict == false) break; // } // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...