답안 #1101681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101681 2024-10-16T15:20:24 Z Mighilon COVID tests (CEOI24_covid) C++17
50.29 / 100
2350 ms 504 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';
}
bool ask2(int l,int sz){
    return ask(l,l+sz-1);
}

int f(int L, int R){
    int m=R-L+1;
    int l=L;
    int sz=0;
    F0Rd(k,LOG+1){
        if(sz+(1<<k)>m)
            continue;
        if(sz==m-1){
            return R;
        }
        dbg(k, L+sz+(1<<k))
        bool b=ask2(L, sz+(1<<k));
        if(!b)
            sz+=1<<k;
    }
    return L+sz;
}

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:57:9: warning: unused variable 'l' [-Wunused-variable]
   57 |     int l=L;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 336 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 7 ms 336 KB Output is correct
5 Correct 7 ms 336 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 7 ms 504 KB Output is correct
8 Correct 7 ms 336 KB Output is correct
9 Correct 8 ms 336 KB Output is correct
10 Correct 5 ms 336 KB Output is correct
11 Correct 6 ms 336 KB Output is correct
12 Correct 7 ms 336 KB Output is correct
13 Correct 7 ms 336 KB Output is correct
14 Correct 6 ms 336 KB Output is correct
15 Correct 8 ms 336 KB Output is correct
16 Correct 7 ms 336 KB Output is correct
17 Correct 8 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 336 KB Output is correct (P=0.001, F=15.1, Q=11.4) -> 90.00 points
2 Correct 123 ms 336 KB Output is correct (P=0.005256, F=51.1, Q=47.9) -> 90.00 points
3 Correct 251 ms 336 KB Output is correct (P=0.011546, F=94.9, Q=95.0) -> 89.62 points
4 Correct 534 ms 336 KB Output is correct (P=0.028545, F=191.5, Q=210.7) -> 64.24 points
5 Correct 638 ms 336 KB Output is correct (P=0.039856, F=246.3, Q=264.0) -> 69.91 points
6 Correct 956 ms 336 KB Output is correct (P=0.068648, F=366.2, Q=375.1) -> 82.03 points
7 Correct 1445 ms 336 KB Output is correct (P=0.104571, F=490.3, Q=607.8) -> 45.95 points
8 Correct 1649 ms 336 KB Output is correct (P=0.158765, F=639.1, Q=663.7) -> 77.99 points
9 Correct 2350 ms 336 KB Output is correct (P=0.2, F=731.4, Q=957.0) -> 40.29 points