# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
772706 | cadmiumsky | Counting Mushrooms (IOI20_mushrooms) | C++17 | 0 ms | 208 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 all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
int f(int x) { return (x + 1) / 2; }
int count_mushrooms(int n) {
int cnt[2] = {1, 0};
vector<int> known[2];
known[0].emplace_back(0);
for(int i = 1; i < n;) {
int T = (sz(known[0]) > sz(known[1])? 0 : 1);
vector<int> cquery;
int j;
for(j = i; j < n && j - i < sz(known[T]); j++)
cquery.emplace_back(known[T][j - i]),
cquery.emplace_back(i);
//cerr << i << ":\n";
//for(auto x : cquery) cerr << x << ' ';
int A = use_machine(cquery);
//cerr << "\n" << A << "\n--\n";
cnt[T ^ 1] += f(A);
cnt[T] += sz(cquery) / 2 - f(A);
known[T ^ (A % 2)].emplace_back(cquery.back());
i = j;
}
return cnt[0];
}
/**
Anul asta se da centroid.
-- Surse oficiale
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |