제출 #405622

#제출 시각아이디문제언어결과실행 시간메모리
405622kostia244버섯 세기 (IOI20_mushrooms)C++17
0 / 100
2 ms220 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; const int C = 100; int count_mushrooms(int n) { vector<int> a{0}, b; for(int i = 1; i < min(n, C); i++) { if(max(a.size(), b.size()) > 1 && i+2 < min(n, C)) { if(a.size()>1) { int t = use_machine({a[0], i, a[1], i+1}); ((t&2) ? b : a).push_back(i); ((t&1) ? b : a).push_back(i+1); } else { int t = use_machine({b[0], i, b[1], i+1}); ((t&2) ? a : b).push_back(i); ((t&1) ? a : b).push_back(i+1); } i++; } else (use_machine({0, i}) ? b : a).push_back(i); } int acc = a.size(), T = 0; if(a.size() < b.size()) swap(a, b), T = 1; for(int pos = C; pos < n;) { vector<int> cur; for(int i = 0; i <= a.size(); i++) { if(pos < n) cur.push_back(pos++); if(i && i < a.size() && pos < n) cur.push_back(pos++); if(i < a.size()) cur.push_back(a[i]); } //for(auto i : cur) cout << i << " "; cout << endl; int t = use_machine(cur); //int res = cur[0] * (t&1 ? -1 : 1); acc += T ? t : ((cur.size() - a.size()) - t); //cout << acc << endl; //(res < 0 ? b : a).push_back(abs(res)); //if(a.size() < b.size()) swap(a, b), T ^= 1; } return acc; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |      for(int i = 0; i <= a.size(); i++) {
      |                     ~~^~~~~~~~~~~
mushrooms.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       if(i && i < a.size() && pos < n) cur.push_back(pos++);
      |               ~~^~~~~~~~~~
mushrooms.cpp:30:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |       if(i < a.size()) cur.push_back(a[i]);
      |          ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...