Submission #1055599

# Submission time Handle Problem Language Result Execution time Memory
1055599 2024-08-12T23:28:15 Z Trent Counting Mushrooms (IOI20_mushrooms) C++17
54.8544 / 100
12 ms 1368 KB
#include "mushrooms.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef vector<ll> vll;
typedef set<int> si;

int count_mushrooms(int n) {
	int IVL = n <= 200 ? 1 : 130;
	vi chk;
	for(int i = 0; i < n; i += IVL) chk.push_back(i);
	if(chk.back() < n-1) chk.push_back(n-1);
	vi ty(chk.size());
	ty[0] = 0;
	REP(i, 1, chk.size()) {
		vi tst = {0, chk[i]};
		ty[i] = use_machine(tst) == 0 ? 0 : 1;
	}

	vi ac, bc;
	forR(i, chk.size()) {
		if(ty[i] == 0) ac.push_back(chk[i]);
		else bc.push_back(chk[i]);
	}
	vb usd(n, false);
	for(int i : chk) usd[i] = true;
	si emp;
	forR(i, n) if(!usd[i]) emp.insert(i);

	int tot = ac.size();
	while(!emp.empty()) {
		int amt = min(max(ac.size(), bc.size()), emp.size() + 1);
		if(ac.size() > bc.size()) {
			vi qu;
			forR(i, amt - 1) {
				qu.push_back(ac[i]);
				qu.push_back(*emp.begin());
				emp.erase(qu.back());
			}
			qu.push_back(ac[amt - 1]);
			int ret = use_machine(qu);
			cerr << qu.size() << ' ' << ret << '\n';
			tot += amt - 1 - ret / 2;
		} else {
			vi qu;
			forR(i, amt - 1) {
				qu.push_back(bc[i]);
				qu.push_back(*emp.begin());
				emp.erase(qu.back());
			}
			qu.push_back(bc[amt - 1]);
			int ret = use_machine(qu);
			cerr << qu.size() << ' ' << ret << '\n';
			tot += ret / 2;
		}
	}
	return tot;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:5:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define REP(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
mushrooms.cpp:20:2: note: in expansion of macro 'REP'
   20 |  REP(i, 1, chk.size()) {
      |  ^~~
mushrooms.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
mushrooms.cpp:26:2: note: in expansion of macro 'forR'
   26 |  forR(i, chk.size()) {
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Partially correct 2 ms 344 KB Output is partially correct
7 Partially correct 8 ms 1368 KB Output is partially correct
8 Partially correct 6 ms 1368 KB Output is partially correct
9 Partially correct 6 ms 1148 KB Output is partially correct
10 Partially correct 7 ms 1368 KB Output is partially correct
11 Partially correct 10 ms 1368 KB Output is partially correct
12 Partially correct 7 ms 1368 KB Output is partially correct
13 Partially correct 7 ms 1368 KB Output is partially correct
14 Partially correct 4 ms 856 KB Output is partially correct
15 Partially correct 8 ms 1368 KB Output is partially correct
16 Partially correct 7 ms 1368 KB Output is partially correct
17 Partially correct 5 ms 704 KB Output is partially correct
18 Partially correct 6 ms 1368 KB Output is partially correct
19 Partially correct 7 ms 1368 KB Output is partially correct
20 Partially correct 6 ms 1368 KB Output is partially correct
21 Partially correct 8 ms 1368 KB Output is partially correct
22 Partially correct 6 ms 1304 KB Output is partially correct
23 Partially correct 7 ms 1368 KB Output is partially correct
24 Partially correct 5 ms 856 KB Output is partially correct
25 Partially correct 7 ms 1368 KB Output is partially correct
26 Partially correct 8 ms 1368 KB Output is partially correct
27 Partially correct 11 ms 1368 KB Output is partially correct
28 Partially correct 8 ms 1368 KB Output is partially correct
29 Partially correct 7 ms 1368 KB Output is partially correct
30 Partially correct 8 ms 1368 KB Output is partially correct
31 Partially correct 12 ms 1368 KB Output is partially correct
32 Partially correct 7 ms 1368 KB Output is partially correct
33 Partially correct 7 ms 1368 KB Output is partially correct
34 Partially correct 7 ms 1292 KB Output is partially correct
35 Partially correct 7 ms 1368 KB Output is partially correct
36 Partially correct 7 ms 1368 KB Output is partially correct
37 Partially correct 7 ms 1368 KB Output is partially correct
38 Partially correct 6 ms 1368 KB Output is partially correct
39 Partially correct 7 ms 1368 KB Output is partially correct
40 Partially correct 7 ms 1368 KB Output is partially correct
41 Partially correct 7 ms 1368 KB Output is partially correct
42 Partially correct 6 ms 1368 KB Output is partially correct
43 Partially correct 7 ms 1172 KB Output is partially correct
44 Partially correct 7 ms 1368 KB Output is partially correct
45 Partially correct 6 ms 1224 KB Output is partially correct
46 Partially correct 10 ms 1368 KB Output is partially correct
47 Partially correct 7 ms 1368 KB Output is partially correct
48 Partially correct 7 ms 1368 KB Output is partially correct
49 Partially correct 7 ms 1368 KB Output is partially correct
50 Partially correct 7 ms 1368 KB Output is partially correct
51 Partially correct 7 ms 1368 KB Output is partially correct
52 Partially correct 8 ms 1368 KB Output is partially correct
53 Partially correct 6 ms 1368 KB Output is partially correct
54 Partially correct 7 ms 1260 KB Output is partially correct
55 Partially correct 7 ms 1368 KB Output is partially correct
56 Partially correct 7 ms 1368 KB Output is partially correct
57 Partially correct 7 ms 1368 KB Output is partially correct
58 Partially correct 7 ms 1368 KB Output is partially correct
59 Partially correct 9 ms 1368 KB Output is partially correct
60 Partially correct 6 ms 1368 KB Output is partially correct
61 Partially correct 6 ms 1236 KB Output is partially correct
62 Correct 0 ms 344 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 0 ms 344 KB Output is correct
68 Correct 1 ms 344 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Correct 0 ms 344 KB Output is correct
73 Correct 0 ms 344 KB Output is correct
74 Correct 0 ms 344 KB Output is correct
75 Correct 0 ms 344 KB Output is correct
76 Correct 1 ms 344 KB Output is correct
77 Correct 0 ms 344 KB Output is correct
78 Correct 0 ms 344 KB Output is correct
79 Correct 0 ms 344 KB Output is correct
80 Correct 0 ms 344 KB Output is correct
81 Correct 0 ms 344 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 0 ms 344 KB Output is correct
84 Correct 0 ms 344 KB Output is correct
85 Correct 1 ms 344 KB Output is correct
86 Correct 0 ms 344 KB Output is correct
87 Correct 0 ms 344 KB Output is correct
88 Correct 0 ms 344 KB Output is correct
89 Correct 0 ms 344 KB Output is correct
90 Correct 0 ms 344 KB Output is correct
91 Correct 0 ms 344 KB Output is correct