# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1035347 | Mr_Husanboy | 버섯 세기 (IOI20_mushrooms) | C++17 | 79 ms | 596 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
template<typename T>
int len(T &a){return a.size();}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int count_mushrooms(int n) {
if(n < 5){
int ans = 1;
for(int i = 1; i < n; i ++){
ans += use_machine({0, i}) ^ 1;
}
return ans;
}
vector<int> a = {0}, b;
for(int i = 1; i < 3; i ++){
if(use_machine({0, i})){
b.push_back(i);
}else a.push_back(i);
}
int ans = len(a);
if(len(a) >= 2){
for(int i = 3; i + 1 < n; i += 2){
int c = use_machine({a[0], i, a[1], i + 1});
ans += 2 - __builtin_popcount(c);
}
}else{
for(int i = 3; i + 1 < n; i += 2){
int c = use_machine({b[0], i, b[1], i + 1});
ans += __builtin_popcount(c);
}
}
if(n % 2 == 0){
ans += use_machine({0, n - 1}) ^ 1;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |