# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
772354 | ono_de206 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 2 ms | 208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int bl = 138;
int solve(int x, int y, int n) {
queue<int> m;
for(int i = 0; i < n; i++) {
if(i != x && i != y) m.push(i);
}
m.push(-1);
vector<int> a, b;
a.pb(x); a.pb(y);
for(int i = 0; i < bl && m.size() > 1; i++) {
int cx = m.front(); m.pop();
int cy = m.front(); m.pop();
int tmp = 0;
if(cy == -1) {
tmp = use_machine(vector<int>{x, cx});
} else {
tmp = use_machine(vector<int>{x, cy, y, cx});
}
if(tmp % 2 == 0) a.pb(cx);
else b.pb(cx);
if(cy != -1) {
if(tmp <= 1) a.pb(cy);
else b.pb(cy);
}
}
bool did = 0;
if(b.size() > a.size()) {
swap(a, b);
did = 1;
}
vector<int> ask;
int ret = (int)a.size(), id = 0;
while(m.size() > 1) {
if(id == a.size()) {
ret += (use_machine(ask) + 1) / 2;
ask.clear();
id = 0;
}
int now = m.front(); m.pop();
ask.pb(a[id++]);
ask.pb(now);
}
if(ask.size()) {
ret += (use_machine(ask) + 1) / 2;
}
if(did) ret = n - ret;
return ret;
}
int count_mushrooms(int n) {
if(n == 2) return n - use_machine(vector<int>{0, 1});
vector<int> a, b;
int A = 1;
a.pb(0);
if(use_machine(vector<int>{0, 1}) == 1) b.pb(1);
else a.pb(1);
if(use_machine(vector<int>{0, 2}) == 1) b.pb(2);
else a.pb(2);
if(a.size() >= 2) {
A = solve(a[0], a[1], n);
} else {
A = n - solve(b[0], b[1], n);
}
return A;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |