Submission #989000

# Submission time Handle Problem Language Result Execution time Memory
989000 2024-05-27T09:47:00 Z AdamGS Counting Mushrooms (IOI20_mushrooms) C++17
25 / 100
68 ms 1024 KB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>OP[64];
int maska[64], V[64][9];
int solve(int v, vector<int>T) {
  if(OP[v].size()==0) return maska[v];
  vector<int>P;
  for(auto i : OP[v]) P.pb(T[i]);
  int x=use_machine(P);
  return solve(V[v][x], T);
}
int count_mushrooms(int n) {
OP[0]={0,1,5,2,6,3};
maska[0]=0;
V[0][0]=1;
OP[1]={0,4};
maska[1]=0;
V[1][0]=2;
OP[2]={};
maska[2]=31;
V[1][1]=3;
OP[3]={};
maska[3]=15;
V[1][2]=4;
OP[4]={};
maska[4]=0;
V[1][3]=5;
OP[5]={};
maska[5]=0;
V[1][4]=6;
OP[6]={};
maska[6]=0;
V[1][5]=7;
OP[7]={};
maska[7]=0;
V[1][6]=8;
OP[8]={};
maska[8]=0;
V[1][7]=9;
OP[9]={};
maska[9]=0;
V[1][8]=10;
OP[10]={};
maska[10]=0;
V[0][1]=11;
OP[11]={2,0,5,1,6,4};
maska[11]=0;
V[11][0]=12;
OP[12]={};
maska[12]=23;
V[11][1]=13;
OP[13]={};
maska[13]=7;
V[11][2]=14;
OP[14]={};
maska[14]=30;
V[11][3]=15;
OP[15]={};
maska[15]=14;
V[11][4]=16;
OP[16]={};
maska[16]=28;
V[11][5]=17;
OP[17]={};
maska[17]=12;
V[11][6]=18;
OP[18]={};
maska[18]=0;
V[11][7]=19;
OP[19]={};
maska[19]=0;
V[11][8]=20;
OP[20]={};
maska[20]=0;
V[0][2]=21;
OP[21]={1,5,0,6,4,7,3,2,8};
maska[21]=0;
V[21][0]=22;
OP[22]={};
maska[22]=0;
V[21][1]=23;
OP[23]={};
maska[23]=27;
V[21][2]=24;
OP[24]={};
maska[24]=29;
V[21][3]=25;
OP[25]={};
maska[25]=11;
V[21][4]=26;
OP[26]={};
maska[26]=13;
V[21][5]=27;
OP[27]={};
maska[27]=22;
V[21][6]=28;
OP[28]={};
maska[28]=20;
V[21][7]=29;
OP[29]={};
maska[29]=6;
V[21][8]=30;
OP[30]={};
maska[30]=4;
V[0][3]=31;
OP[31]={1,2,0,8,5,3,6,4,7};
maska[31]=0;
V[31][0]=32;
OP[32]={};
maska[32]=0;
V[31][1]=33;
OP[33]={};
maska[33]=24;
V[31][2]=34;
OP[34]={};
maska[34]=26;
V[31][3]=35;
OP[35]={};
maska[35]=8;
V[31][4]=36;
OP[36]={};
maska[36]=10;
V[31][5]=37;
OP[37]={};
maska[37]=21;
V[31][6]=38;
OP[38]={};
maska[38]=19;
V[31][7]=39;
OP[39]={};
maska[39]=5;
V[31][8]=40;
OP[40]={};
maska[40]=3;
V[0][4]=41;
OP[41]={2,1,0,5,3,6,4};
maska[41]=0;
V[41][0]=42;
OP[42]={};
maska[42]=0;
V[41][1]=43;
OP[43]={};
maska[43]=25;
V[41][2]=44;
OP[44]={};
maska[44]=9;
V[41][3]=45;
OP[45]={};
maska[45]=16;
V[41][4]=46;
OP[46]={};
maska[46]=0;
V[41][5]=47;
OP[47]={};
maska[47]=18;
V[41][6]=48;
OP[48]={};
maska[48]=2;
V[41][7]=49;
OP[49]={};
maska[49]=0;
V[41][8]=50;
OP[50]={};
maska[50]=0;
V[0][5]=51;
OP[51]={0,4};
maska[51]=0;
V[51][0]=52;
OP[52]={};
maska[52]=17;
V[51][1]=53;
OP[53]={};
maska[53]=1;
V[51][2]=54;
OP[54]={};
maska[54]=0;
V[51][3]=55;
OP[55]={};
maska[55]=0;
V[51][4]=56;
OP[56]={};
maska[56]=0;
V[51][5]=57;
OP[57]={};
maska[57]=0;
V[51][6]=58;
OP[58]={};
maska[58]=0;
V[51][7]=59;
OP[59]={};
maska[59]=0;
V[51][8]=60;
OP[60]={};
maska[60]=0;
V[0][6]=61;
OP[61]={};
maska[61]=0;
V[0][7]=62;
OP[62]={};
maska[62]=0;
V[0][8]=63;
OP[63]={};
maska[63]=0;
  vector<int>A, B;
  A.pb(0);
  int l=1;
  while(B.size()==0 && l<n) {
    int x=min(n-l, (int)A.size()+1);
    vector<int>T;
    int po=l;
    T.pb(l++);
    rep(i, x-1) {
      T.pb(A[i]);
      T.pb(l++);
    }
    if(x==1) T.pb(A[0]);
    int ko=l-1;
    int a=use_machine(T);
    if(a==0) {
      while(po<=ko) A.pb(po++);
      continue;
    }
    while(po<ko) {
      int sr=(po+ko)/2;
      T.clear();
      T.pb(po);
      rep(i, sr-po) {
        T.pb(A[i]);
        T.pb(po+i+1);
      }
      if(po==sr) T.pb(A[0]);
      a=use_machine(T);
      if(a==0) {
        while(po<=sr) A.pb(po++);
      } else ko=sr;
    }
    B.pb(po);
    l=po+1;
  }
  while(max(A.size(), B.size())<3 && l<n) {
    int x=use_machine({0, l});
    if(x==0) A.pb(l); else B.pb(l);
    ++l;
  }
  rep(i, n) {
    if(l+5>n) break;
    vector<int>T;
    rep(i, 5) T.pb(l++);
    if(A.size()>=3) {
      rep(i, 3) T.pb(A[i]);
      T.pb(B[0]);
    } else {
      rep(i, 3) T.pb(B[i]);
      T.pb(A[0]);
    }
    int x=solve(0, T);
    if(A.size()>=3) {
      rep(j, 5) if(x&(1<<j)) A.pb(T[j]); else B.pb(T[j]);
    } else {
      rep(j, 5) if(x&(1<<j)) B.pb(T[j]); else A.pb(T[j]);
    }
  }
  while(l<n) {
    int x=use_machine({0, l});
    if(x==0) A.pb(l); else B.pb(l);
    ++l;
  }
  return A.size();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Partially correct 6 ms 708 KB Output is partially correct
7 Partially correct 38 ms 740 KB Output is partially correct
8 Partially correct 43 ms 892 KB Output is partially correct
9 Partially correct 40 ms 460 KB Output is partially correct
10 Partially correct 52 ms 548 KB Output is partially correct
11 Partially correct 47 ms 768 KB Output is partially correct
12 Partially correct 56 ms 728 KB Output is partially correct
13 Partially correct 54 ms 728 KB Output is partially correct
14 Partially correct 26 ms 864 KB Output is partially correct
15 Partially correct 51 ms 504 KB Output is partially correct
16 Partially correct 52 ms 728 KB Output is partially correct
17 Partially correct 22 ms 488 KB Output is partially correct
18 Partially correct 59 ms 616 KB Output is partially correct
19 Partially correct 64 ms 480 KB Output is partially correct
20 Partially correct 56 ms 948 KB Output is partially correct
21 Partially correct 43 ms 600 KB Output is partially correct
22 Partially correct 61 ms 760 KB Output is partially correct
23 Partially correct 44 ms 748 KB Output is partially correct
24 Partially correct 30 ms 508 KB Output is partially correct
25 Partially correct 52 ms 592 KB Output is partially correct
26 Partially correct 46 ms 540 KB Output is partially correct
27 Partially correct 44 ms 760 KB Output is partially correct
28 Partially correct 58 ms 784 KB Output is partially correct
29 Partially correct 50 ms 736 KB Output is partially correct
30 Partially correct 53 ms 600 KB Output is partially correct
31 Partially correct 48 ms 716 KB Output is partially correct
32 Partially correct 51 ms 592 KB Output is partially correct
33 Partially correct 65 ms 592 KB Output is partially correct
34 Partially correct 53 ms 600 KB Output is partially correct
35 Partially correct 62 ms 596 KB Output is partially correct
36 Partially correct 44 ms 848 KB Output is partially correct
37 Partially correct 54 ms 684 KB Output is partially correct
38 Partially correct 48 ms 776 KB Output is partially correct
39 Partially correct 63 ms 504 KB Output is partially correct
40 Partially correct 52 ms 724 KB Output is partially correct
41 Partially correct 47 ms 512 KB Output is partially correct
42 Partially correct 56 ms 732 KB Output is partially correct
43 Partially correct 61 ms 592 KB Output is partially correct
44 Partially correct 58 ms 600 KB Output is partially correct
45 Partially correct 48 ms 592 KB Output is partially correct
46 Partially correct 48 ms 716 KB Output is partially correct
47 Partially correct 47 ms 596 KB Output is partially correct
48 Partially correct 53 ms 520 KB Output is partially correct
49 Partially correct 50 ms 508 KB Output is partially correct
50 Partially correct 60 ms 700 KB Output is partially correct
51 Partially correct 53 ms 592 KB Output is partially correct
52 Partially correct 48 ms 848 KB Output is partially correct
53 Partially correct 68 ms 488 KB Output is partially correct
54 Partially correct 54 ms 592 KB Output is partially correct
55 Partially correct 68 ms 724 KB Output is partially correct
56 Partially correct 65 ms 844 KB Output is partially correct
57 Partially correct 49 ms 764 KB Output is partially correct
58 Partially correct 45 ms 752 KB Output is partially correct
59 Partially correct 58 ms 600 KB Output is partially correct
60 Partially correct 50 ms 1024 KB Output is partially correct
61 Partially correct 52 ms 604 KB Output is partially correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 0 ms 344 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Correct 0 ms 344 KB Output is correct
73 Correct 1 ms 344 KB Output is correct
74 Correct 0 ms 344 KB Output is correct
75 Correct 0 ms 344 KB Output is correct
76 Correct 1 ms 344 KB Output is correct
77 Correct 0 ms 344 KB Output is correct
78 Correct 0 ms 344 KB Output is correct
79 Correct 1 ms 344 KB Output is correct
80 Correct 0 ms 344 KB Output is correct
81 Correct 0 ms 344 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 0 ms 344 KB Output is correct
85 Correct 0 ms 344 KB Output is correct
86 Correct 0 ms 344 KB Output is correct
87 Correct 0 ms 344 KB Output is correct
88 Correct 0 ms 344 KB Output is correct
89 Correct 0 ms 344 KB Output is correct
90 Correct 0 ms 344 KB Output is correct
91 Correct 0 ms 344 KB Output is correct