Submission #772463

#TimeUsernameProblemLanguageResultExecution timeMemory
772463t6twotwoCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
8 ms344 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int N) { int ans = 1; vector<int> T[] = {{0}, {}}; for (int i = 1, z = 0; i < N; z = T[1].size() > T[0].size()) { int K = min(N - i, (int)T[z].size()); vector<int> v; for (int j = 0; j < K; j++) { v.push_back(T[z][j]); v.push_back(i++); } int x = use_machine(v); if (z) { ans += x / 2 + x % 2; } else { ans += K - x / 2 - x % 2; } T[z ^ x & 1].push_back(i - 1); } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:20:17: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   20 |         T[z ^ x & 1].push_back(i - 1);
      |               ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...