# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303733 | 2020-09-20T15:29:57 Z | kylych03 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 3 ms | 512 KB |
#include <bits/stdc++.h> #include "mushrooms.h" //#include "stub.cpp" using namespace std; int count_mushrooms(int n) { vector<int> m; vector <int> a,b; srand(time(0)); for (int i = 0; i < n; i++) m.push_back(i); random_shuffle(m.begin()+1, m.end()); int cnt = 0; int l=1; vector <int> vec1; vec1.push_back(0); vec1.push_back(m[1]); a.push_back(0); if(!use_machine(vec1)) a.push_back(m[1]); else b.push_back(m[1]); vec1[1]=m[2]; if(n>2) if(use_machine(vec1)==0) a.push_back(m[2]); else b.push_back(m[2]); l=3; cnt = a.size(); while(l < n && max(a.size(), b.size()) <70 ){ if(a.size()>= b.size()){ vector <int> vec; for(int i = 0 ; i < a.size() && l<n; i++){ vec.push_back(a[i]); vec.push_back(m[l]); l++; } int res = use_machine(vec); if(res%2==1) b.push_back(vec[vec.size()-1]); else a.push_back(vec[vec.size()-1]); cnt +=(vec.size()/2 - (res+1)/2); } else{ vector <int> vec; for(int i = 0 ; i < b.size() && l<n; i++){ vec.push_back(b[i]); vec.push_back(m[l]); l++; } int res = use_machine(vec); if(res%2==0) b.push_back(vec[vec.size()-1]); else a.push_back(vec[vec.size()-1]); cnt +=((res+1)/2); } } return cnt; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Incorrect | 3 ms | 512 KB | Answer is not correct. |
8 | Halted | 0 ms | 0 KB | - |