제출 #1072806

#제출 시각아이디문제언어결과실행 시간메모리
1072806IgnutCounting Mushrooms (IOI20_mushrooms)C++17
25 / 100
84 ms600 KiB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int use_machine(vector<int> x);

int count_mushrooms(int n) {
    int res = 1;
    int firstA = 0, secondA = -1;
    vector<int> vec;
    for (int i = 1; i < n; i ++) vec.push_back(i);
    while (vec.size() > 1) {
        int u = vec.back(); vec.pop_back();
        int v = vec.back(); vec.pop_back();
        if (secondA != -1) {
            int val = use_machine({firstA, u, secondA, v});
            if (val == 0) res += 2;
            else if (val == 1) res ++;
            else if (val == 2) res ++;
            continue; 
        }
        int val = use_machine({u, firstA, v});
        if (val == 0) {
            secondA = u;
            res += 2;
        }
        else if (val == 1) {
            res ++;
            val = use_machine({firstA, u});
            if (val == 0)
                secondA = u;
            else
                secondA = v;
        }
    }
    if (!vec.empty()) {
        int val = use_machine({firstA, vec.back()});
        if (val == 0) res ++;
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...