# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1032229 | hotboy2703 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 1248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL<<(i))
ll use(vector <ll> tmp){
return use_machine(tmp);
}
int count_mushrooms(int n) {
if (n==2){
return 2 - use({0,1});
}
vector <ll> c[2];
c[0].push_back(0);
c[use({0,1})].push_back(1);
c[use({0,2})].push_back(2);
ll ptr = 3;
ll res = 0;
while (ptr < n){
if (max(sz(c[0]),sz(c[1])) >= 80){
ll id = 0;
if (sz(c[1]) > sz(c[0]))id = 1;
vector <ll> tmp;
for (ll j = 0;j < sz(c[id]) && ptr < n;j ++,ptr++){
tmp.push_back(c[id][j]);
tmp.push_back(ptr);
}
ll cur = use(tmp);
if (cur%2)c[1-id].push_back(tmp.back());
else c[id].push_back(tmp.back());
if (id==1)res += cur/2;
else res += sz(tmp)/2 - (cur/2+1);
}
else{
if (ptr + 1 < n){
if (sz(c[0]) >= 2){
ll tmp = use({ptr,c[0][0],ptr+1,c[0][1]});
c[BIT(tmp,0)].push_back(ptr);
c[BIT(tmp,1)].push_back(ptr+1);
}
else{
ll tmp = use({ptr,c[1][0],ptr+1,c[1][1]});
c[1-BIT(tmp,0)].push_back(ptr);
c[1-BIT(tmp,1)].push_back(ptr+1);
}
ptr+=2;
}
else{
c[use({0,ptr})].push_back(ptr);
ptr++;
}
}
}
res += sz(c[0]);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |