제출 #420672

#제출 시각아이디문제언어결과실행 시간메모리
420672ioi버섯 세기 (IOI20_mushrooms)C++14
45.38 / 100
14 ms304 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 <= 100 ; i ++){ if(!use_machine({0 , i}))A.push_back(i) , ans ++ ; else B.push_back(i); } if(A.size() > B.size()){ int p = 101 ; 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 = 101 ; 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 ; }

컴파일 시 표준 에러 (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...