제출 #697072

#제출 시각아이디문제언어결과실행 시간메모리
697072garam1732Counting Mushrooms (IOI20_mushrooms)C++14
56.50 / 100
10 ms312 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; vector<int> a, b; int cnt = 100; int count_mushrooms(int n) { a.push_back(0); std::vector<int> m; for(int i = 1; i < n && i <= 2*cnt; i++) { m = {0, i}; int x = use_machine(m); if(x) b.push_back(i); else a.push_back(i); } if(a.size() + b.size() == n) return a.size(); int res = a.size(); if(a.size() >= cnt) { int idx = 2*cnt+1; while(idx < n) { m.clear(); m.push_back(a[0]); for(int i = 1; i < a.size(); i++) { if(idx < n) m.push_back(idx++); m.push_back(a[i]); } res += (int)m.size()-(int)a.size()-use_machine(m)/2; } } else { int idx = 2*cnt+1; while(idx < n) { m.clear(); m.push_back(b[0]); for(int i = 1; i < b.size(); i++) { if(idx < n) m.push_back(idx++); m.push_back(b[i]); } res += use_machine(m)/2; } } return res; }

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:20:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  if(a.size() + b.size() == n) return a.size();
      |     ~~~~~~~~~~~~~~~~~~~~^~~~
mushrooms.cpp:23:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |  if(a.size() >= cnt) {
      |     ~~~~~~~~~^~~~~~
mushrooms.cpp:28:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int i = 1; i < a.size(); i++) {
      |                            ~~^~~~~~~~~~
mushrooms.cpp:41:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for(int i = 1; i < b.size(); i++) {
      |                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...