제출 #817400

#제출 시각아이디문제언어결과실행 시간메모리
817400math_rabbit_1028버섯 세기 (IOI20_mushrooms)C++14
0 / 100
1 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int b = max((int)sqrt(n), 2); vector<int> Alist, Blist; Alist.push_back(0); int i; for (i = 1; i < n; i++) { if (use_machine({i, Alist[0]}) == 0) Alist.push_back(i); else Blist.push_back(i); if (Alist.size() == b || Blist.size() == b) break; } i++; int ans = Alist.size(); for (; i < n; i += (b-1)) { vector<int> seq; if (Alist.size() == b) { seq.push_back(Alist[0]); for (int j = i; j < min(i + b - 1, n); j++) { seq.push_back(j); seq.push_back(Alist[j - i + 1]); } ans += b - 1 - use_machine(seq) / 2; } else { seq.push_back(Blist[0]); for (int j = i; j < min(i + b - 1, n); j++) { seq.push_back(j); seq.push_back(Blist[j - i + 1]); } ans += use_machine(seq) / 2; } } return ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:14:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |         if (Alist.size() == b || Blist.size() == b) break;
      |             ~~~~~~~~~~~~~^~~~
mushrooms.cpp:14:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |         if (Alist.size() == b || Blist.size() == b) break;
      |                                  ~~~~~~~~~~~~~^~~~
mushrooms.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if (Alist.size() == b) {
      |             ~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...