Submission #1101676

# Submission time Handle Problem Language Result Execution time Memory
1101676 2024-10-16T15:11:20 Z Mighilon COVID tests (CEOI24_covid) C++17
0 / 100
48 ms 592 KB
#include <bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#include "../Library/debug.h"
#else
#define dbg(x...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first 
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
 
const char nl = '\n';
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
int n, LOG;
double p;
int block;
vector<bool> ans;

bool ask(int l, int r){
    cout<<"Q ";
    string s(n,'0');
    FOR(i,l,r+1)
        s[i]='1';
    cout<<s;
    cout<<endl;
    char ans;
    cin>>ans;
    return ans=='P';
}

int f(int L, int R){
    int l=L, r=R;
    int res=l;
    // vb tmp(R-L+1,0);
    // if(L==R)
    //     return L;
    // while(l<=r){
    //     int m=(l+r)/2;
    //     bool b=ask(l,m);
    //     tmp[m]=b;
    //     if(m==R)
    //         return m;
    //     if(!b&&(m+1==R||(m+1<R&&tmp[m+1])))
    //         return m+1;
    //     if(b){
    //         res=m;
    //         r=m-1;
    //     }
    //     else{
    //         l=m+1;
    //     }
    // }

    if(L==R){
        return L;
    }
    res=0;
    F0Rd(k,LOG+1){
        if(L+res+(1<<k)>=R)
            continue;
        if(L+res+1==R){
            return R;
        }
        dbg(k, L+res+(1<<k))
        bool b=ask(L, L+res+(1<<k)-1);
        if(!b)
            res+=1<<k;
    }
    return L+res;
}

void solve(){
    int i=0;
    while(i<n){
        bool b=ask(i,min(n-1,i+block-1));
        if(!b)
            i+=block;
        else{
            int j=f(i,min(n-1,i+block-1));
            ans[j]=1;
            i=j+1;
        }
    }
    cout<<"A ";
    F0R(i,n)
        cout<<ans[i];
    cout<<endl;
    char c;
    cin>>c;
}
 
int32_t main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int TC = 1;
    // cin >> TC;
    cin>>n>>p>>TC;
    block=1;
    double tmp=p;
    while(tmp+p<=0.5&&p!=0){
        block++;
        tmp+=p;
    }
    LOG=block?__builtin_clz(1)-__builtin_clz(block):-1;
    ans.resize(n);
    while(TC--){
        ans.assign(n,0);
        solve();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int first(int, int)':
Main.cpp:53:14: warning: unused variable 'r' [-Wunused-variable]
   53 |     int l=L, r=R;
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 336 KB Output is correct
2 Correct 9 ms 336 KB Output is correct
3 Correct 7 ms 336 KB Output is correct
4 Correct 6 ms 336 KB Output is correct
5 Correct 9 ms 336 KB Output is correct
6 Correct 7 ms 336 KB Output is correct
7 Correct 9 ms 336 KB Output is correct
8 Correct 7 ms 336 KB Output is correct
9 Correct 9 ms 336 KB Output is correct
10 Incorrect 6 ms 336 KB translate:wrong
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 48 ms 336 KB Output is correct (P=0.001, F=15.1, Q=11.3) -> 90.00 points
2 Runtime error 4 ms 592 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -