Submission #1050451

# Submission time Handle Problem Language Result Execution time Memory
1050451 2024-08-09T09:42:51 Z dozer Comparing Plants (IOI20_plants) C++14
14 / 100
4000 ms 5996 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define LL node * 2
#define RR node * 2 + 1
#define ll long long
#define MAXN 200005

const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;

int val[MAXN];

void init(int k, vector<int> r) {
	int n = r.size();
	vector<int> done(n, 0);
	vector<int> todo;
	for (int i = 0; i < n; i++){
		if (r[i] == 0) done[i] = -1;
	}

	int cntr = 0;
	int sum = 0;
	while(sum < n){
		int start = 0;
		for (int i = 0; i < n; i++) if (done[i] == -1) start = i;

		for (int i = 0; i < n; i++){
			if (done[i] != -1) continue;
			int nxt = i + 1;
			while(done[nxt] != -1) nxt = (nxt + 1) % n;
			if ((nxt - i + n) % n >= k) start = nxt;
		}
		val[start] = cntr++;
		done[start] = 1;
		sum++;
		for (int j = 1; j <= k - 1; j++){
			int to = (start - j + n) % n; 
			r[to]--;
			if (r[to] == 0 && done[to] == 0) done[to] = -1;
		}
	}
}

int compare_plants(int x, int y) {
	if (val[x] > val[y]) return -1;
	return 1;
}

/*
static int n, k, q;
static std::vector<int> r;
static std:: vector<int> x;
static std:: vector<int> y;
static std:: vector<int> answer;
int main() {
	fileio();
	assert(scanf("%d%d%d", &n, &k, &q) == 3);
	r.resize(n);
	answer.resize(q);
	for (int i = 0; i < n; i++) {
		int value;
		assert(scanf("%d", &value) == 1);
		r[i] = value;
	}
	x.resize(q);
	y.resize(q);
	for (int i = 0; i < q; i++) {
		assert(scanf("%d%d", &x[i], &y[i]) == 2);
	}
	fclose(stdin);

	init(k, r);
	for (int i = 0; i < q; i++) {
		answer[i] = compare_plants(x[i], y[i]);
	}

	for (int i = 0; i < q; i++) {
		printf("%d\n", answer[i]);
	}

	fclose(stdout);

	return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 520 KB Output is correct
7 Correct 178 ms 3128 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 163 ms 3340 KB Output is correct
11 Correct 149 ms 3156 KB Output is correct
12 Correct 162 ms 3332 KB Output is correct
13 Correct 171 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 520 KB Output is correct
7 Correct 178 ms 3128 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 163 ms 3340 KB Output is correct
11 Correct 149 ms 3156 KB Output is correct
12 Correct 162 ms 3332 KB Output is correct
13 Correct 171 ms 3152 KB Output is correct
14 Correct 1964 ms 3324 KB Output is correct
15 Execution timed out 4069 ms 5996 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 38 ms 3096 KB Output is correct
4 Execution timed out 4083 ms 5120 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -