Submission #612447

# Submission time Handle Problem Language Result Execution time Memory
612447 2022-07-29T15:14:57 Z erekle Comparing Plants (IOI20_plants) C++17
5 / 100
87 ms 8688 KB
#include "plants.h"

using namespace std;

int n;
vector<int> greater, less;

void init(int k, vector<int> r) {
	n = r.size();
	greater.resize(n);
	less.resize(n);
	
	// find cross-over
	int start = 0;
	while (r[(start-1+n)%n] == r[start]) ++start;

	int cur = (start-1+n)%n;
	do {
		int nxt = (cur+1)%n;
		if (r[cur]) less[cur] = less[nxt]+1;
		else greater[cur] = greater[nxt]+1;
		cur = (cur-1+n)%n;
	} while ((cur+1)%n != start);
	return;
}

int compare_plants(int x, int y) {
	int sub = (x < y ? 0 : n);
	if (x+greater[x]-sub >= y) return 1;
	if (x+less[x]-sub >= y) return -1;
	sub = n-sub;
	if (y+greater[y]-sub >= x) return -1;
	if (y+less[y]-sub >= x) return 1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 60 ms 4000 KB Output is correct
7 Correct 61 ms 5508 KB Output is correct
8 Correct 80 ms 8656 KB Output is correct
9 Correct 79 ms 8616 KB Output is correct
10 Correct 78 ms 8648 KB Output is correct
11 Correct 76 ms 8676 KB Output is correct
12 Correct 79 ms 8636 KB Output is correct
13 Correct 84 ms 8656 KB Output is correct
14 Correct 87 ms 8688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 292 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 0 ms 288 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 288 KB Output is correct
6 Correct 60 ms 4000 KB Output is correct
7 Correct 61 ms 5508 KB Output is correct
8 Correct 80 ms 8656 KB Output is correct
9 Correct 79 ms 8616 KB Output is correct
10 Correct 78 ms 8648 KB Output is correct
11 Correct 76 ms 8676 KB Output is correct
12 Correct 79 ms 8636 KB Output is correct
13 Correct 84 ms 8656 KB Output is correct
14 Correct 87 ms 8688 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 292 KB Output isn't correct
18 Halted 0 ms 0 KB -