Submission #376381

# Submission time Handle Problem Language Result Execution time Memory
376381 2021-03-11T10:46:23 Z InternetPerson10 Counting Mushrooms (IOI20_mushrooms) C++14
75.0831 / 100
13 ms 492 KB
#include "mushrooms.h"
#include <iostream>

using namespace std;

vector<int> nums, a, b;

int count_mushrooms(int n) {
	int A = 1, B = 0, x;
	bool bb = false;
	nums.push_back(0);
	a.push_back(0);
	nums.push_back(0);
	if(n < 210) {
		for(int i = 1; i < n; i++) {
			nums[1] = i;
			if(use_machine(nums) == 1) B++;
			else A++;
		}
		return A;
	}
	for(int i = 1; i < 3; i++) {
		nums[1] = i;
		if(use_machine(nums) == 0) {
			A++;
			a.push_back(i);
		}
		else {
			B++;
			b.push_back(i);
		}
	}
	if(B >= 2) {
		swap(A, B);
		swap(a, b);
		bb = true;
	}
	nums.resize(4);
	nums[0] = a[0];
	nums[2] = a[1];
	for(int i = 3; i < 199; i += 2) {
		nums[1] = i;
		nums[3] = i+1;
		x = use_machine(nums);
		if(x == 3) {
			B += 2;
			b.push_back(i);
			b.push_back(i+1);
		}
		else if(x == 2) {
			A++; B++;
			b.push_back(i);
			a.push_back(i+1);
		}
		else if(x == 1) {
			A++; B++;
			a.push_back(i);
			b.push_back(i+1);
		}
		else {
			A += 2;
			a.push_back(i);
			a.push_back(i+1);
		}
	}	
	if(bb) {
		swap(a, b);
		swap(A, B);
	}
	bb = false;
	// cout << "A: ";
	// for(int i = 0; i < (int)a.size(); i++) cout << a[i] << ' ';
	// cout << "\n" << A << "\nB: ";
	// for(int i = 0; i < (int)b.size(); i++) cout << b[i] << ' ';
	// cout << "\n" << B << "\n";
	if(B >= 100) {
		swap(a, b);
		swap(A, B);
		bb = true;
	}
	nums.resize(199);
	for(int i = 199; i < n; i += 99) {
		for(int j = 0; j < 100; j++) {
			nums[2*j] = a[j];
		}
		if(i + 99 >= n) {
			for(int j = 0; i+j < n; j++) {
				nums[2*j+1] = i+j;
				x = j;
			}
			x++;
			int y = 0;
			for(int j = 0; j < (int)b.size() && x < 99; j++) {
				nums[2*x+1] = b[j];
				x++;
				y++;
				// cout << "Yay assigned " << 2*(x)+1 << " to " << b[j] << '\n';
			}
			for(int j = 0; 100+j < (int)a.size() && x < 99; j++) {
				nums[2*x+1] = a[j+100];
				x++;
				// cout << "Yay assigned " << 2*(x)+1 << " to " << a[j+100] << '\n';
			}
			// for(int i = 0; i < (int)nums.size(); i++) cout << nums[i] << ' ';
			// cout << '\n';
			x = use_machine(nums);
			// cout << "Ooh I got " << x << '\n';
			x /= 2;
			x -= y;
			// cout << "owo i'm left with " << x << '\n';
			B += x;
			A += (n-i) - x;
			// cout << "Ok now it's " << A << ' ' << B << '\n';
		}
		else {
			for(int j = 0; j < 99; j++) {
				nums[2*j+1] = i+j;
			}
			x = use_machine(nums);
			x /= 2;
			B += x;
			A += 99 - x;
		}
	}
	if(bb) {
		swap(a, b);
		swap(A, B);
	}
	return A;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Partially correct 10 ms 364 KB Output is partially correct
8 Partially correct 8 ms 364 KB Output is partially correct
9 Partially correct 8 ms 364 KB Output is partially correct
10 Partially correct 9 ms 364 KB Output is partially correct
11 Partially correct 9 ms 384 KB Output is partially correct
12 Partially correct 9 ms 268 KB Output is partially correct
13 Partially correct 13 ms 364 KB Output is partially correct
14 Correct 5 ms 364 KB Output is correct
15 Partially correct 8 ms 364 KB Output is partially correct
16 Partially correct 7 ms 364 KB Output is partially correct
17 Correct 5 ms 364 KB Output is correct
18 Partially correct 8 ms 364 KB Output is partially correct
19 Partially correct 10 ms 364 KB Output is partially correct
20 Partially correct 7 ms 384 KB Output is partially correct
21 Partially correct 8 ms 364 KB Output is partially correct
22 Partially correct 8 ms 364 KB Output is partially correct
23 Partially correct 9 ms 364 KB Output is partially correct
24 Correct 6 ms 364 KB Output is correct
25 Partially correct 10 ms 364 KB Output is partially correct
26 Partially correct 8 ms 364 KB Output is partially correct
27 Partially correct 8 ms 364 KB Output is partially correct
28 Partially correct 10 ms 364 KB Output is partially correct
29 Partially correct 10 ms 364 KB Output is partially correct
30 Partially correct 8 ms 364 KB Output is partially correct
31 Partially correct 7 ms 364 KB Output is partially correct
32 Partially correct 9 ms 364 KB Output is partially correct
33 Partially correct 10 ms 364 KB Output is partially correct
34 Partially correct 7 ms 364 KB Output is partially correct
35 Partially correct 9 ms 364 KB Output is partially correct
36 Partially correct 9 ms 364 KB Output is partially correct
37 Partially correct 7 ms 364 KB Output is partially correct
38 Partially correct 10 ms 364 KB Output is partially correct
39 Partially correct 8 ms 364 KB Output is partially correct
40 Partially correct 8 ms 364 KB Output is partially correct
41 Partially correct 10 ms 492 KB Output is partially correct
42 Partially correct 8 ms 396 KB Output is partially correct
43 Partially correct 9 ms 364 KB Output is partially correct
44 Partially correct 7 ms 384 KB Output is partially correct
45 Partially correct 9 ms 364 KB Output is partially correct
46 Partially correct 9 ms 364 KB Output is partially correct
47 Partially correct 10 ms 364 KB Output is partially correct
48 Partially correct 8 ms 364 KB Output is partially correct
49 Partially correct 7 ms 364 KB Output is partially correct
50 Partially correct 9 ms 364 KB Output is partially correct
51 Partially correct 8 ms 364 KB Output is partially correct
52 Partially correct 8 ms 364 KB Output is partially correct
53 Partially correct 9 ms 364 KB Output is partially correct
54 Partially correct 10 ms 364 KB Output is partially correct
55 Partially correct 10 ms 364 KB Output is partially correct
56 Partially correct 9 ms 364 KB Output is partially correct
57 Partially correct 10 ms 364 KB Output is partially correct
58 Partially correct 8 ms 364 KB Output is partially correct
59 Partially correct 10 ms 364 KB Output is partially correct
60 Partially correct 10 ms 364 KB Output is partially correct
61 Partially correct 9 ms 364 KB Output is partially correct
62 Correct 1 ms 364 KB Output is correct
63 Correct 1 ms 364 KB Output is correct
64 Correct 1 ms 384 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Correct 1 ms 364 KB Output is correct
67 Correct 1 ms 364 KB Output is correct
68 Correct 1 ms 364 KB Output is correct
69 Correct 1 ms 364 KB Output is correct
70 Correct 1 ms 364 KB Output is correct
71 Correct 1 ms 364 KB Output is correct
72 Correct 0 ms 364 KB Output is correct
73 Correct 1 ms 364 KB Output is correct
74 Correct 1 ms 364 KB Output is correct
75 Correct 1 ms 364 KB Output is correct
76 Correct 1 ms 364 KB Output is correct
77 Correct 1 ms 364 KB Output is correct
78 Correct 1 ms 364 KB Output is correct
79 Correct 1 ms 364 KB Output is correct
80 Correct 1 ms 492 KB Output is correct
81 Correct 1 ms 364 KB Output is correct
82 Correct 0 ms 364 KB Output is correct
83 Correct 0 ms 364 KB Output is correct
84 Correct 1 ms 364 KB Output is correct
85 Correct 1 ms 364 KB Output is correct
86 Correct 1 ms 364 KB Output is correct
87 Correct 1 ms 364 KB Output is correct
88 Correct 1 ms 364 KB Output is correct
89 Correct 0 ms 364 KB Output is correct
90 Correct 1 ms 364 KB Output is correct
91 Correct 0 ms 364 KB Output is correct