Submission #610359

#TimeUsernameProblemLanguageResultExecution timeMemory
610359Jomnoi버섯 세기 (IOI20_mushrooms)C++17
0 / 100
7 ms304 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; int result; vector <int> x; vector <int> typeA, typeB; int count_mushrooms(int N) { typeA.push_back(0); int i = 1; while(typeA.size() < 140 and typeB.size() < 140 and i < N) { result = use_machine({0, i}); if(result == 1) { typeB.push_back(i); } else { typeA.push_back(i); } i++; } int numberofA = 0, cnt; while(i < N) { if(typeA.size() > typeB.size()) { x.clear(); cnt = 0; for(int j = 0; j < typeA.size() - 1 and i < N; j++) { x.push_back(typeA[j]); x.push_back(i++); cnt++; } x.push_back(typeA.back()); result = use_machine(x); numberofA += cnt - result / 2; } else { x.clear(); cnt = 0; for(int j = 0; j < typeB.size() - 1 and i < N; j++) { x.push_back(typeB[j]); x.push_back(i++); cnt++; } x.push_back(typeA.back()); result = use_machine(x); numberofA += result / 2; } } return numberofA + typeA.size(); }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for(int j = 0; j < typeA.size() - 1 and i < N; j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~
mushrooms.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    for(int j = 0; j < typeB.size() - 1 and i < N; j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...