Submission #1301898

#TimeUsernameProblemLanguageResultExecution timeMemory
1301898opeleklanosCounting Mushrooms (IOI20_mushrooms)C++20
25 / 100
28 ms400 KiB
#include <iostream>
#include <vector>
#include "mushrooms.h"
using namespace std;

// bool ans[] = {1, 0, 0, 1, 0, 1, 1, 1, 0};

// int use_machine(vector<int> v){
//     int curr = ans[v[0]];
//     int a = 0;
//     for(int i = 1; i<v.size(); i++){
//         if(ans[v[i]] != curr) a++;
//         curr = ans[v[i]];
//     }
//     return a;
// }


int count_mushrooms(int n){
    int ans = 1;
    for(int i = 1; i<n-1; i+=2){
        int tmp = use_machine({i, 0, i+1});
        if(tmp == 0) ans += 2;
        if(tmp == 1) ans += 1;
    }
    if(n%2==0 && use_machine({0, n-1}) == 0) ans++;
    return ans;
}

// int main(void){
//     cout<<count_mushrooms(9);
// }
#Verdict Execution timeMemoryGrader output
Fetching results...