제출 #1051706

#제출 시각아이디문제언어결과실행 시간메모리
1051706TahirAliyev버섯 세기 (IOI20_mushrooms)C++17
0 / 100
19 ms344 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define ll long long #define all(v) v.begin(), v.end() #define oo 1e9 const int B = 200; int count_mushrooms(int n){ int ans = 0, cur = 0, t = 0; vector<int> id; for(int i = 0; i < n; i++) id.push_back(i); random_shuffle(id.begin() + 1, id.end()); vector<int> one; while(one.size() < B && cur + 1 < n){ vector<int> v; for(int i = cur; i < min(cur + B, n); i++) v.push_back(id[i]); if(!use_machine(v)){ if(t) for(int i = cur; i < min(cur + B, n); i++) one.push_back(i); else ans += v.size(); t ^= 1; cur += B; continue; } int l = cur, r = min(cur + B, n) - 1; while(l < r){ int mid = (l + r + 1) / 2; vector<int> v; for(int i = l; i <= mid; i++) v.push_back(id[i]); if(!use_machine(v)) l = mid; else r = mid - 1; } if(t) for(int i = cur; i <= l; i++) one.push_back(i); else ans += l - cur + 1; t ^= 1; cur = l + 1; } if(cur == n - 2){ ans += (t == 0); cur++; } while(cur < n){ vector<int> v; for(int i = 0; i < one.size() && cur < n; i++, cur++){ v.push_back(id[one[i]]); v.push_back(id[cur]); } ans += (use_machine(v) + 1) / 2; } return ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 0; i < one.size() && cur < n; i++, cur++){
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...