Submission #1067461

#TimeUsernameProblemLanguageResultExecution timeMemory
1067461Lalic버섯 세기 (IOI20_mushrooms)C++17
0 / 100
73 ms344 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(). x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<double> cd; int solve(int a, int b, int i, int n){ if(i>=n) return 0; if(i==n-1) return use_machine({a, i}); int val=use_machine({a, i, b, i+1}); int sum=0; if(val&2) sum++; if(val&1) sum++; return sum+solve(a, b, i+2, n); } int count_mushrooms(int n) { int temp=use_machine({0, 1}); int tot; if(!temp) tot=solve(0, 1, 2, n); else{ int cnt=2, comp=-1; tot=1; for(;cnt+1<n;cnt+=2){ int curr=use_machine({1, cnt, cnt+1}); if(!curr) tot+=2; if(curr==1){ tot+=use_machine({0, cnt}); comp=cnt+1; cnt+=2; break; } else{ tot++; comp=cnt; cnt+=2; break; } } tot+=solve(0, comp, cnt, n); } return n-tot; }
#Verdict Execution timeMemoryGrader output
Fetching results...