Submission #1295202

#TimeUsernameProblemLanguageResultExecution timeMemory
1295202lambd47COVID tests (CEOI24_covid)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)

std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());

int n;double p;


void solve() {
    int block=(double)(1)/p;//ver melhor constante 
    if(block==0)block=1;
    block=__lg(block);
    block=(1<<(block));

    if(abs(0.2 - p) <= EPS) block = 5;
    if(abs(0.104571 - p) <= EPS) block  = 7;

    vector<int> resp(n,0);
    vector<int> aux(n,0);
    auto ask=[&](int l, int r)->bool{
        L(i,l,r)aux[i]=1;
        cout<<"Q ";
        L(i,0,n-1)cout<<aux[i];
        cout<<endl;
        L(i,l,r)aux[i]=0;
        char c;cin>>c;
        return c=='P';
    };

    auto busca=[&](auto&& self, int l, int r){
        int m=(l+r)/2;
        if(l==r){
            resp[l]=1;
            return l;
        }
        if(ask(l,m))return self(self,l,m);
        else return self(self,m+1,r);
    };

    int at=0;

    while(at<n){
        int rat=min(n-1,at+block-1);
        if(ask(at,rat))at=busca(busca,at,rat)+1;
        else at=at+block;
    }

    cout<<"A ";
    for(auto a:resp)cout<<a;
    cout<<endl;
    char c;cin>>c;

}
 
int32_t main() {
    int T = 1;
//    std::cin >> T;
    cin>>n>>p>>T;
    while(T--) {
        solve();
    }

	return 0;
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:21:24: error: 'EPS' was not declared in this scope
   21 |     if(abs(0.2 - p) <= EPS) block = 5;
      |                        ^~~
Main.cpp:22:29: error: 'EPS' was not declared in this scope
   22 |     if(abs(0.104571 - p) <= EPS) block  = 7;
      |                             ^~~