제출 #721464

#제출 시각아이디문제언어결과실행 시간메모리
721464vjudge1버섯 세기 (IOI20_mushrooms)C++17
0 / 100
4 ms208 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 = 10; 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; if(As.size() >= Bs.size()){ int i = unt; for(; i < n;){ vector<int> search; int j = 0; for(; j < As.size() && i < n; j++, i++){ search.push_back(i); search.push_back(As[j]); } int q = use_machine(search); cnt += (j + 1) - ((q/2) + q % 2); } } else{ int i = unt; for(; i < n; ){ vector<int> search; for(int j = 0; j < Bs.size() && i < n; j++, i++){ search.push_back(i); search.push_back(Bs[j]); } 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; }

컴파일 시 표준 에러 (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++, i++){
      |                   ~~^~~~~~~~~~~
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++, i++){
      |                            ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...