제출 #424063

#제출 시각아이디문제언어결과실행 시간메모리
424063Mohammed_Atalah버섯 세기 (IOI20_mushrooms)C++17
45.29 / 100
19 ms552 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> indices; for (int i = 0; i < n; i++) { indices.push_back(i); } if (use_machine(indices) == 0) { return n; } int bs = 0; int as = 1; vector<int> a; vector<int> b; int last_index; for (int i = 1; i < n; i++) { std::vector<int> v; v.push_back(0); v.push_back(i); if (use_machine(v) == 1) { bs++; b.push_back(i); } else { as++; a.push_back(i); } if (a.size() == 200 || b.size() == 200) { last_index = i + 1; break; } } if (a.size() != 200 && b.size() != 200) { return n - bs; } int remain = n - last_index; if (a.size() == 200) { while (remain > 0) { if (remain >= 199) { vector<int> v; v.push_back(a[0]); for (int i = 1; i < 200; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= 199; } else { vector<int> v; v.push_back(a[0]); for (int i = 1; i < remain + 1; i++) { v.push_back(last_index); v.push_back(a[i]); last_index++; } bs += use_machine(v) / 2; remain -= remain; } } return n - bs; } else if (b.size() == 200) { while (remain > 0) { if (remain >= 199) { vector<int> v; v.push_back(b[0]); for (int i = 1; i < 200; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= 199; // cout << as << endl; } else { vector<int> v; v.push_back(b[0]); for (int i = 1; i < remain + 1 ; i++) { v.push_back(last_index); v.push_back(b[i]); last_index++; } as += use_machine(v) / 2; remain -= remain; } } return as; } }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:8:14: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  vector<int> indices;
      |              ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...