Submission #987753

# Submission time Handle Problem Language Result Execution time Memory
987753 2024-05-23T14:30:22 Z AdamGS Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
1 ms 448 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 && p==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 && p==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 Correct 1 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 Incorrect 1 ms 448 KB Answer is not correct.
7 Halted 0 ms 0 KB -