Submission #947119

#TimeUsernameProblemLanguageResultExecution timeMemory
947119steveonalexCombo (IOI18_combo)C++14
100 / 100
17 ms2088 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){ string a = ans + string(1, pool[hot[0]]); string b = ans + string(1, pool[hot[1]]); string p = a; for(int j: hot) p += b + string(1, pool[j]); int verdict = press(p); if (verdict == i-1){ ans += string(1, pool[hot[2]]); } else if (verdict == i) { ans += string(1, pool[hot[0]]); } else ans += string(1, pool[hot[1]]); } if (ans.size() < n){ for(int i:hot){ if (i != hot.back()) { if (press(ans + string(1, pool[i])) == n){ ans.push_back(pool[i]); break; } } else ans.push_back(pool[i]); } } return ans; } // bool solve(int _n, string _a){ // query_cnt = 0; // n = _n; a = _a; // string b = guess_sequence(n); // cout << "! " << b << "\n"; // return a == b; // } // } // int main(void){ // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int n; cin >> n; // string a; cin >> a; // bool verdict = Interactor::solve(n, a); // if (verdict) cout << "AC\n"; // else cout << "WA\n"; // return 0; // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:96:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   96 |         if (ans.size() < n){
      |             ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...