답안 #1094637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094637 2024-09-30T07:37:36 Z epicci23 COVID tests (CEOI24_covid) C++17
10 / 100
7000 ms 852 KB
#include "bits/stdc++.h"
//#define int long long
#define double long double
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
 
int BL=1,n,tc;
double P;
vector<bool> cur,A;

bool test_students(vector<bool> mask){
  cout << "Q ";
  for(int x:mask) cout << x;
  cout << '\n' << flush; 
  char answer; cin >> answer;
  return answer == 'P';
}
 
bool Ask(vector<int> Mask){
  for(int x:Mask) cur[x]=1;
  bool res = test_students(cur);
  for(int x:Mask) cur[x]=0;
  return res;
}

double Fast(double x,int u){
  if(u==0) return 1.0L;
  double res=Fast(x,u/2);
  res*=res;
  if(u&1) res*=x;
  return res;
}

 
vector<bool> find_positive(){
  auto calc_prob = [&](int g) { return 1.0L - Fast(1.0L - P, g); };
  auto eval = [&](double d) { return abs(d - 0.5L); };

  BL=1;
  while(eval(calc_prob(BL+1))<eval(calc_prob(BL))) ++BL;
  if(P==0.104571) ++BL;

  A.assign(n,0);
  vector<int> g1(n,0),g2;
  iota(all(g1),0);

  while(sz(g1) || sz(g2)){
    if(sz(g2)){

     if(sz(g2)==1){
      A[g2[0]]=1;
      g2.clear();
      continue;
     }

     int cur_BL=1;
     while(eval(calc_prob(cur_BL + 1) / calc_prob(sz(g2))) <
      eval(calc_prob(cur_BL) / calc_prob(sz(g2))))
      ++cur_BL;

     vector<int> sor;
     int hm = sz(g2);
     for(int j=0;j<min(hm,cur_BL);j++){
      sor.push_back(g2.back());
      g2.pop_back();
     }

     if(Ask(sor)){
       g1.insert(end(g1),all(g2));
       g2=sor;
     }

    }
    else{
      vector<int> sor;
      int hm = sz(g1);
      for(int j=0;j<min(hm,BL);j++){
       sor.push_back(g1.back());
       g1.pop_back();
      }
      if(Ask(sor)) g2=sor;
    }
  }

  return A;
}
 
void _(){
  vector<bool> GG=find_positive();
  cout << "A ";
  for(bool x:GG) cout << x;
  cout << '\n' << flush;
  char son; cin >> son;
  if(son=='C') return;
  else exit(0);
}
 
int32_t main(){
  cin.tie(0); ios::sync_with_stdio(0);
  cin >> n >> P >> tc;
  cur.assign(n,0);
  while(tc--) _();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 344 KB Output is correct
2 Correct 30 ms 344 KB Output is correct
3 Correct 31 ms 344 KB Output is correct
4 Correct 34 ms 344 KB Output is correct
5 Correct 31 ms 344 KB Output is correct
6 Correct 33 ms 344 KB Output is correct
7 Correct 32 ms 344 KB Output is correct
8 Correct 39 ms 344 KB Output is correct
9 Correct 31 ms 344 KB Output is correct
10 Correct 21 ms 344 KB Output is correct
11 Correct 32 ms 344 KB Output is correct
12 Correct 31 ms 344 KB Output is correct
13 Correct 31 ms 344 KB Output is correct
14 Correct 47 ms 344 KB Output is correct
15 Correct 30 ms 344 KB Output is correct
16 Correct 47 ms 344 KB Output is correct
17 Correct 51 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 344 KB Output is correct (P=0.001, F=15.1, Q=11.0) -> 90.00 points
2 Correct 475 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=46.6) -> 90.00 points
3 Correct 979 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=91.0) -> 90.00 points
4 Correct 1942 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=188.4) -> 90.00 points
5 Correct 2529 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=244.6) -> 90.00 points
6 Correct 3801 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=364.9) -> 90.00 points
7 Correct 5154 ms 852 KB Output is correct (P=0.104571, F=490.3, Q=492.2) -> 88.63 points
8 Correct 6706 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=633.0) -> 90.00 points
9 Execution timed out 7037 ms 344 KB Time limit exceeded
10 Halted 0 ms 0 KB -