Submission #423980

#TimeUsernameProblemLanguageResultExecution timeMemory
423980Mohammed_AtalahCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms200 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> indices; for (int i = 0; i < n; i++) { indices.push_back(i); } if (use_machine(indices) == 0) { return n; } int bs = 0; int as = 0; vector<int> a; vector<int> b; int last_index; for (int i = 1; i < n; i++) { std::vector<int> v; v.push_back(0); v.push_back(i); if (use_machine(v) == 1) { bs++; b.push_back(i); } else { as++; a.push_back(i); } if (a.size() == 20 || b.size() == 20) { last_index = i + 1; break; } } if (a.size() != 20 && b.size() != 20) { return n - bs; } int remain = n - last_index; if (a.size() == 20) { while (remain > 0) { if (remain >= 19) { vector<int> v; v.push_back(a[0]); for (int i = 1; i < 20; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= 19; } else { vector<int> v; v.push_back(a[0]); for (int i = 1; i < remain + 1; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= remain; } } return n - bs; } else if (b.size() == 20) { while (remain > 0) { if (remain >= 19) { vector<int> v; v.push_back(b[0]); for (int i = 1; i < 20; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= 19; } else { vector<int> v; v.push_back(b[0]); for (int i = 1; i < remain + 1; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= remain; } } return as; } }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:8:14: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  vector<int> indices;
      |              ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...