# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1065896 | n1k | 버섯 세기 (IOI20_mushrooms) | C++17 | 7 ms | 600 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 "mushrooms.h"
#define ll long long
#define vt vector
#define pb push_back
#define ar array
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
using namespace std;
/*
1. simplify
2. add new elements
3. brute force solution
4. optimize
5. start implementing
*/
// --- templates ---
// --- code ---
const int take = 144 * 2;
int count_mushrooms(int n){
vt<vt<int>> shrom(2);
shrom[0].pb(0);
for(int i = 1; i < min(3, n); i++){
shrom[use_machine({0, i})].pb(i);
}
vt<int> find(4);
bool isb = shrom[1].size() >= 2;
find[1] = shrom[isb][0];
find[3] = shrom[isb][1];
for(int i = 3; i < take + 3 && i < n; i+=2){
if(i == n - 1){
shrom[use_machine({0, i})].pb(i);
}else{
find[0] = i; find[2] = i + 1;
int res = use_machine(find);
shrom[(res & 1) ^ isb].pb(i);
shrom[((res & 2) >> 1) ^ isb].pb(i + 1);
}
}
int cnta = sz(shrom[0]);
for(int i = take + 3; i < n; i += sz(shrom[isb])){
find.clear();
for(int j = 0; j < sz(shrom[isb]) && i + j < n; j++){
find.pb(shrom[isb][j]);
find.pb(i + j);
}
int res = use_machine(find);
if(isb){
cnta += (res + 1) / 2;
}else{
cnta += sz(find) / 2 - (res + 1) / 2;
}
}
return cnta;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |