Submission #721498

#TimeUsernameProblemLanguageResultExecution timeMemory
721498vjudge1버섯 세기 (IOI20_mushrooms)C++17
56.78 / 100
12 ms348 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define N '\n'; #define VI <vector <int>> #define VVI <vector <vector <int>>> int count_mushrooms(int n){ int cnt = 1; if(n <= 226){ for(int i = 1; i < n; i++){ cnt += 1 - use_machine({0, i}); } return cnt; } vector <int> As = {0}; vector <int> Bs; int unt = 188; for(int i = 1; i < unt; i++){ bool q = use_machine({0,i}); if(q) Bs.push_back(i); else As.push_back(i); } cnt += As.size()-1; int i = unt; if(As.size() >= Bs.size()){ for(; i < n;){ vector<int> search; int j = 0; for(; j < As.size() && i < n; j++ ){ search.push_back(i); search.push_back(As[j]); i++; } int q = use_machine(search); cnt += (search.size()/2) - ((q/2) +(q % 2)); } } else{ for(; i < n; ){ vector<int> search; for(int j = 0; j < Bs.size() && i < n; j++){ search.push_back(i); search.push_back(Bs[j]); i++; } int q = use_machine(search); cnt += q/2 + q % 2; } } // B A B A B A // B A A A B A B A return cnt; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(; j < As.size() && i < n; j++ ){
      |                   ~~^~~~~~~~~~~
mushrooms.cpp:48:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int j = 0; j < Bs.size() && i < n; j++){
      |                            ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...