Submission #304397

#TimeUsernameProblemLanguageResultExecution timeMemory
304397QAQAutoMatonCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
12 ms396 KiB
#include "mushrooms.h" #include<algorithm> int min(int x,int y){return x<y?x:y;} int count_mushrooms(int n) { std::vector<int> A({0}),B(0),ask; int ans=1; int at=1; while(at<n){ ask.clear(); if(A.size()>B.size()){ int m=min(A.size(),n-at); for(int i=0;i<m;++i){ ask.emplace_back(at+i); ask.emplace_back(A[i]); } int w=use_machine(ask); (w&1?B:A).emplace_back(at); ans+=m-((w+1)>>1); at+=m; }else{ int m=min(B.size(),n-at); for(int i=0;i<m;++i){ ask.emplace_back(at+i); ask.emplace_back(B[i]); } int w=use_machine(ask); (w&1?A:B).emplace_back(at); ans+=((w+1)>>1); at+=m; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...