Submission #420691

#TimeUsernameProblemLanguageResultExecution timeMemory
420691ioiCounting Mushrooms (IOI20_mushrooms)C++14
56.78 / 100
13 ms320 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std ; int count_mushrooms(int n) { int ans = 1 ; if (n <= 200){ for(int i = 1 ; i < n ; i ++) ans += !use_machine({0 , i}); return ans ; } vector<int> A , B ; A .push_back(0); for(int i = 1 ; i <= 200 ; i ++){ if(!use_machine({0 , i}))A.push_back(i) , ans ++ ; else B.push_back(i); } if(A.size() > B.size()){ int p = 201 ; while(p < n){ vector<int> tocheck ; tocheck.push_back(0); int curr = 0 ; for(int i = 1 ; i < A.size() && p < n ; i ++){ tocheck.push_back(p++); tocheck.push_back(A[i]); curr ++ ; } int c = use_machine(tocheck); ans += (curr - c / 2); } } else { int p = 201 ; while(p < n){ vector<int> tocheck ; tocheck.push_back(B[0]); int curr = 0 ; for(int i = 1 ; i < B.size() && p < n ; i ++){ tocheck.push_back(p++); tocheck.push_back(B[i]); curr ++ ; } int c = use_machine(tocheck); ans += c / 2; } } return ans ; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:39:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i = 1 ; i < A.size() && p < n ; i ++){
      |                             ~~^~~~~~~~~~
mushrooms.cpp:62:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for(int i = 1 ; i < B.size() && p < n ; i ++){
      |                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...