Submission #947111

# Submission time Handle Problem Language Result Execution time Memory
947111 2024-03-15T14:01:06 Z steveonalex Combo (IOI18_combo) C++14
0 / 100
1 ms 344 KB
#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 x = ans + string(1, pool[hot[1]]);
            string y = ans + string(1, pool[hot[2]]);
            string p = x;
            for(int j: hot) p += y + string(1, pool[j]);

            int v = press(p);
            if (v == i-1) ans.push_back(pool[0]);
            else if (v == i) ans.push_back(pool[1]);
            else if (v == i+1) ans.push_back(pool[2]);
            else exit(1);
        }
        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 time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Wrong Answer: wrong guess.
6 Halted 0 ms 0 KB -