# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1001513 | 2024-06-19T05:13:11 Z | irmuun | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 344 KB |
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int count_mushrooms(int n){ int ans=0; vector<int>a,b; a.pb(0); for(int i=1;i<min(n,200);i++){ int d=use_machine({0,i}); if(d==0){ a.pb(i); } else{ b.pb(i); } } if(n<200){ return (int)a.size(); } ans=a.size(); if(b.size()>a.size()){ int len=b.size(); len-=2; for(int i=200;i<n;i+=len){ int r=min(i+len,n-1); int cur=0; vector<int>v; v.pb(b[0]); for(int j=i;j<=r;j++){ v.pb(j); v.pb(b[++cur]); } for(int j=cur+1;j<b.size();j++){ v.pb(b[j]); } ans+=use_machine(v)/2; } } else{ int len=a.size(); len-=2; for(int i=200;i<n;i+=len){ int r=min(i+len,n-1); int cur=0; vector<int>v; v.pb(b[0]); int cnt=0; for(int j=i;j<=r;j++){ v.pb(j); cnt++; v.pb(a[++cur]); } for(int j=cur+1;j<a.size();j++){ v.pb(a[j]); } ans+=cnt-use_machine(v)/2; } } return ans; }
Compilation message
# | 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 | 0 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Incorrect | 1 ms | 344 KB | Answer is not correct. |
7 | Halted | 0 ms | 0 KB | - |