Submission #884582

#TimeUsernameProblemLanguageResultExecution timeMemory
884582jamjanekCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
0 ms344 KiB
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; const int stala = 2; int maska[4] = {0,0,3,1,}; vector<int>zapytanie[4] = {{0,1,},{0,1,2,},{},{},}; vector<int>graf[4] = {{1,4,},{2,3,},{},{},}; vector<int>A[2]; int Ac[2]; int it; int count_mushrooms1(int n){ while(it<n){ // printf("it = %d\n", it); vector<int>pom; bool czy = 0; if(A[1].size()>A[0].size())czy = 1; int pom1 = 0; while(it<n && pom.size()<2*A[czy].size()){ pom.push_back(A[czy][pom1++]); pom.push_back(it); it++; } int ans = use_machine(pom); // printf("vec: = ");for(auto j: pom)printf("%d ", j);printf("\n"); // printf("ans = %d\n", ans); if(ans%2==0) A[czy].push_back(it-1); else A[!czy].push_back(it-1); Ac[!czy]+=(ans+1)/2; Ac[czy]+=pom1-(ans+1)/2; if(pom1==2){ if(ans<2) A[czy].push_back(it-2); else A[!czy].push_back(it-2); } } // printf("res = %d\n", Ac[0]); return Ac[0]; } int count_mushrooms(int n){ A[0].push_back(0); it = 1; Ac[0] = 1; Ac[1] = 0; if(n<=stala+1) return count_mushrooms1(n); int x = 0; while(graf[x].size()>0){ int c = use_machine(zapytanie[x]); x = graf[x][c]; } x = maska[x]; for(int i=0;i<stala;i++){ if((x>>i)&1){ A[1].push_back(i+1); Ac[1]++; } else{ A[0].push_back(i+1); Ac[0]++; } } it = stala+1; return count_mushrooms1(n); }
#Verdict Execution timeMemoryGrader output
Fetching results...