제출 #721507

#제출 시각아이디문제언어결과실행 시간메모리
721507vjudge1버섯 세기 (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 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 mn = 10000, ans; for(int i = 1; i < 500; i++){ if(2*i + ((n - (2*i)) / i) < mn){ mn = 2*i + ((n - (2*i)) / i); ans = i; } } int unt = ans*2; // 188 - 1 = 187 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; vector <int> Is; // n - 188 / 94 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); is.push_back(i); search.push_back(As[j]); i++; } int q = use_machine(search); cnt += (search.size()/2) - ((q/2) +(q % 2)); if(q/2 + q % 2 == 0){ for(int i = 0; i < Is.size(); i++){ As.push_back(Is[i]); } } } } else{ for(; i < n; ){ vector<int> search; for(int j = 0; j < Bs.size() && i < n; j++){ search.push_back(i); is.push_back(i); search.push_back(Bs[j]); i++; } int q = use_machine(search); cnt += q/2 + q % 2; if(q/2 + q % 2 == 0){ for(int i = 0; i < Is.size(); i++){ Bs.push_back(Is[i]); } } } } // 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:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(; j < As.size() && i < n; j++ ){
      |                   ~~^~~~~~~~~~~
mushrooms.cpp:50:17: error: 'is' was not declared in this scope; did you mean 'Is'?
   50 |                 is.push_back(i);
      |                 ^~
      |                 Is
mushrooms.cpp:57:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |                 for(int i = 0; i < Is.size(); i++){
      |                                ~~^~~~~~~~~~~
mushrooms.cpp:66:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |             for(int j = 0; j < Bs.size() && i < n; j++){
      |                            ~~^~~~~~~~~~~
mushrooms.cpp:68:17: error: 'is' was not declared in this scope; did you mean 'Is'?
   68 |                 is.push_back(i);
      |                 ^~
      |                 Is
mushrooms.cpp:76:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |                 for(int i = 0; i < Is.size(); i++){
      |                                ~~^~~~~~~~~~~