제출 #305859

#제출 시각아이디문제언어결과실행 시간메모리
305859myungwoo버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms376 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) int count_mushrooms(int N) { const int K = 73; int add = 0; vector <int> arr[2]; arr[0] = {0}; for (int i=1;i<N;i++){ if (arr[0].size() > arr[1].size() && arr[0].size() >= K){ vector <int> test; for (int j=0;j<arr[0].size()&&i+j<N;j++){ test.push_back(arr[0][j]); test.push_back(i+j); } int res = use_machine(test); add += test.size()>>1; add -= res&1; add -= res>>1; i += arr[0].size()-1; arr[res&1].push_back(test.back()); } else if (arr[1].size() >= K){ vector <int> test; for (int j=0;j<arr[1].size()&&i+j<N;j++){ test.push_back(arr[1][j]); test.push_back(i+j); } int res = use_machine(test); add += res&1; add += res>>1; i += arr[1].size()-1; arr[res&1^1].push_back(test.back()); } else if (i+1 < N && arr[0].size() > 1){ int res = use_machine({arr[0][0], i, arr[0][1], i+1}); arr[res>>1&1].push_back(i); arr[res&1].push_back(++i); }else if (i+1 < N && arr[1].size() > 1){ int res = use_machine({arr[1][0], i, arr[1][1], i+1}); arr[res>>1&1^1].push_back(i); arr[res&1^1].push_back(++i); } else arr[use_machine({0, i})].push_back(i); } return arr[0].size() + add; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |    for (int j=0;j<arr[0].size()&&i+j<N;j++){
      |                 ~^~~~~~~~~~~~~~
mushrooms.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for (int j=0;j<arr[1].size()&&i+j<N;j++){
      |                 ~^~~~~~~~~~~~~~
mushrooms.cpp:37:11: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   37 |    arr[res&1^1].push_back(test.back());
      |        ~~~^~
mushrooms.cpp:45:14: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   45 |    arr[res>>1&1^1].push_back(i);
      |        ~~~~~~^~
mushrooms.cpp:46:11: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   46 |    arr[res&1^1].push_back(++i);
      |        ~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...