Submission #603783

# Submission time Handle Problem Language Result Execution time Memory
603783 2022-07-24T11:34:06 Z HamletPetrosyan Comparing Plants (IOI20_plants) C++17
5 / 100
73 ms 5836 KB
#include "plants.h"
#include <iostream>
using namespace std;

#define len(a) ((int)(a).size())

vector<int> p, m;

void init(int k, vector<int> r) {
	p.resize(len(r));
	m.resize(len(r));
	for(int i = 0, pr, now; i < 2 * len(r); i++){
		now = i % len(r);
		pr = (now == 0) ? len(r) - 1 : now - 1;
		p[now] = m[now] = now;
		if(r[pr] == 0){
			p[now] = p[pr];
		}
		else {
			m[now] = m[pr];
		}
	}
//	for(int i = 0; i < len(p); i++){
//		cout << p[i] << " ";
//	}
//	cout << endl;
//	for(int i = 0; i < len(m); i++){
//		cout << m[i] << " ";
//	}
//	cout << endl;
}

int compare_plants(int x, int y) {
	if(x < y){
		if(p[x] > x && p[x] <= y) return -1;
		if(m[y] <= x || m[y] > y) return -1;
		if(m[x] > x && m[x] <= y) return 1;
		if(p[y] <= x || p[y] > y) return 1;
		return 0;
	}
	if(p[x] <= y || p[x] > x) return -1;
	if(m[y] > y && m[y] <= x) return -1;
	if(m[x] <= y || m[x] > x) return 1;
	if(p[y] > y && p[y] <= x) return 1;
	return 0;
}
# 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 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 44 ms 3056 KB Output is correct
7 Correct 55 ms 3376 KB Output is correct
8 Correct 69 ms 5708 KB Output is correct
9 Correct 70 ms 5788 KB Output is correct
10 Correct 73 ms 5744 KB Output is correct
11 Correct 68 ms 5736 KB Output is correct
12 Correct 67 ms 5748 KB Output is correct
13 Correct 64 ms 5708 KB Output is correct
14 Correct 69 ms 5836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 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 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 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 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 212 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 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 44 ms 3056 KB Output is correct
7 Correct 55 ms 3376 KB Output is correct
8 Correct 69 ms 5708 KB Output is correct
9 Correct 70 ms 5788 KB Output is correct
10 Correct 73 ms 5744 KB Output is correct
11 Correct 68 ms 5736 KB Output is correct
12 Correct 67 ms 5748 KB Output is correct
13 Correct 64 ms 5708 KB Output is correct
14 Correct 69 ms 5836 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -