Submission #420698

#TimeUsernameProblemLanguageResultExecution timeMemory
420698ioiCounting Mushrooms (IOI20_mushrooms)C++14
52.31 / 100
13 ms308 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std ; int count_mushrooms(int n) { int ans = 1 ; if (n <= 300){ 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 <= 300 ; i ++){ if(!use_machine({0 , i}))A.push_back(i) , ans ++ ; else B.push_back(i); } if(A.size() > B.size()){ int p = 301 ; 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 = 301 ; 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...