Submission #613674

#TimeUsernameProblemLanguageResultExecution timeMemory
613674Jarif_RahmanCounting Mushrooms (IOI20_mushrooms)C++17
53.81 / 100
12 ms340 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int count_mushrooms(int n){ vector<int> A, B; A.pb(0); int sq = sqrt(n); sq = max(2, sq); int ls = n; for(int i = 1; i < n; i++){ if(max(A.size(), B.size()) == sq){ ls = i; break; } if(use_machine({0, i})) B.pb(i); else A.pb(i); } int ans = A.size(); if(A.size() == sq){ for(int i = ls; i < n; i+=sq){ vector<int> Q; for(int j = 0; j < sq; j++){ Q.pb(A[j]); if(i+j < min(n, i+sq)) Q.pb(i+j); } int x = use_machine(Q); ans+=min(n, i+sq)-i-x%2-x/2; } } else{ for(int i = ls; i < n; i+=sq){ vector<int> Q; for(int j = 0; j < sq; j++){ Q.pb(B[j]); if(i+j < min(n, i+sq)) Q.pb(i+j); } int x = use_machine(Q); ans+=x%2+x/2; } } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:19:36: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   19 |         if(max(A.size(), B.size()) == sq){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
mushrooms.cpp:30:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     if(A.size() == sq){
      |        ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...