Submission #824719

#TimeUsernameProblemLanguageResultExecution timeMemory
824719kwongwengCounting Mushrooms (IOI20_mushrooms)C++17
92.24 / 100
7 ms444 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second #define f use_machine // max # use of f : 280 // goal : 226 /* 60 - 91.8699 */ int lim=70; int count_mushrooms(int n) { int ans=0; vi A, B; A.pb(0); int a=1; int b=0; int cur=1; while (cur < n){ if (a>b){ if (a>=2 && a<=lim && cur<n-1){ int num = f({A[0],cur,A[1],cur+1}); if (num%2==1) {B.pb(cur+1); b++;} else {A.pb(cur+1); a++;} if (num>=2) {B.pb(cur); b++;} else {A.pb(cur); a++;} cur=cur+2; continue; } vi val; int len=0; FOR(i,0,min(a,n-cur)){ val.pb(A[i]); val.pb(cur+i); len+=2; } int num = f(val); ans += len/2-1-num/2; if (num%2==0) {a++; A.pb(val[len-1]);} else {b++; B.pb(val[len-1]);} cur=val[len-1]+1; }else{ if (b>=2 && b<=lim && cur<n-1){ int num = f({B[0],cur,B[1],cur+1}); if (num%2==0) {B.pb(cur+1); b++;} else {A.pb(cur+1); a++;} if (num<2) {B.pb(cur); b++;} else {A.pb(cur); a++;} cur=cur+2; continue; } vi val; int len=0; FOR(i,0,min(b,n-cur)){ val.pb(B[i]); val.pb(cur+i); len+=2; } int num = f(val); ans += num/2; if (num%2==0) {b++; B.pb(val[len-1]);} else {a++; A.pb(val[len-1]);} cur=val[len-1]+1; } } return ans+a; }
#Verdict Execution timeMemoryGrader output
Fetching results...