Submission #300575

# Submission time Handle Problem Language Result Execution time Memory
300575 2020-09-17T09:45:31 Z imeimi2000 Comparing Plants (IOI20_plants) C++17
5 / 100
114 ms 5112 KB
#ifdef imeimi

#include <vector>

void init(int k, std::vector<int> r);
int compare_plants(int x, int y);

#include <cstdio>
#include <cassert>
#include <vector>
#define n N
#define k K

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() {
	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;
}

#undef n
#undef k
#else

#include "plants.h"

#endif

#include <bits/stdc++.h>

using namespace std;

static int n, k;
static int sum[200001];
void init(int k, vector<int> r) {
    ::k = k;
    n = r.size();
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + r[i - 1];
    }
}

int compare_plants(int x, int y) {
    if (k == 2) {
        int cnt = sum[y] - sum[x];
        int max = y - x;
        if (cnt == 0) return 1;
        if (cnt == max) return -1;
        cnt = sum[n] - cnt;
        max = n - max;
        if (cnt == 0) return -1;
        if (cnt == max) return 1;
        return 0;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 62 ms 3192 KB Output is correct
7 Correct 79 ms 3324 KB Output is correct
8 Correct 106 ms 5112 KB Output is correct
9 Correct 105 ms 5112 KB Output is correct
10 Correct 107 ms 4984 KB Output is correct
11 Correct 114 ms 4984 KB Output is correct
12 Correct 103 ms 5112 KB Output is correct
13 Correct 98 ms 4984 KB Output is correct
14 Correct 101 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 416 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 62 ms 3192 KB Output is correct
7 Correct 79 ms 3324 KB Output is correct
8 Correct 106 ms 5112 KB Output is correct
9 Correct 105 ms 5112 KB Output is correct
10 Correct 107 ms 4984 KB Output is correct
11 Correct 114 ms 4984 KB Output is correct
12 Correct 103 ms 5112 KB Output is correct
13 Correct 98 ms 4984 KB Output is correct
14 Correct 101 ms 4984 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Incorrect 1 ms 256 KB Output isn't correct
18 Halted 0 ms 0 KB -