Submission #987752

# Submission time Handle Problem Language Result Execution time Memory
987752 2024-05-23T14:29:27 Z AdamGS Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
1 ms 344 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()
int count_mushrooms(int n) {
  vector<int>A, B;
  A.pb(0);
  int l=1, ans=0;
  while(l<n) {
    if(A.size()>=B.size()) {
      int p=min(n-l, (int)A.size());
      vector<int>T;
      rep(i, p) {
        T.pb(A[i]);
        T.pb(l);
        ++l;
      }
      int x=use_machine(T);
      if(A.size()==2) {
        if(x==0) {
          B.pb(l-2);
          B.pb(l-1);
        } else if(x==1) {
          A.pb(l-2);
          B.pb(l-1);
        } else if(x==2) {
          B.pb(l-2);
          A.pb(l-1);
        } else {
          A.pb(l-2);
          A.pb(l-1);
        }
      } else {
        if(x%2==0) A.pb(l-1); else B.pb(l-1);
        ans+=p-1-x/2;
      }
    } else {
      int p=min(n-l, (int)B.size());
      vector<int>T;
      rep(i, p) {
        T.pb(B[i]);
        T.pb(l);
        ++l;
      }
      int x=use_machine(T);
      if(B.size()==2) {
        if(x==0) {
          A.pb(l-2);
          A.pb(l-1);
        } else if(x==1) {
          B.pb(l-2);
          A.pb(l-1);
        } else if(x==2) {
          A.pb(l-2);
          B.pb(l-1);
        } else {
          B.pb(l-2);
          B.pb(l-1);
        }
      } else {
        if(x%2==0) B.pb(l-1); else A.pb(l-1);
        ans+=x/2;
      }
    }
  }
  ans+=A.size();
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Answer is not correct.
3 Halted 0 ms 0 KB -