# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429186 | abdzag | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 200 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include "mushrooms.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;
using namespace std;
int count_mushrooms(int n) {
ll ans = 0;
vector<int> v(3);
queue<ll> q;
rep(i, 1, n)q.push(i);
while (!q.empty()) {
v[0] = q.front();
q.pop();
if (q.empty()) {
v.pop_back();
ll cur = use_machine(v);
if (cur == 0)ans++;
}
else {
v[2] = q.front();
q.pop();
ll cur = use_machine(v);
if (cur == 0) {
ans += 2;
}
else if (cur == 1) {
ans += 1;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |