Submission #572793

# Submission time Handle Problem Language Result Execution time Memory
572793 2022-06-05T10:06:28 Z kartel Comparing Plants (IOI20_plants) C++14
5 / 100
106 ms 16500 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "plants.h"
#define pb push_back
#define sz(x) (int)x.size()
using namespace std;

const int N = 1e6 + 500;

int le[N], ri[N], n;

void init(int k, vector <int> r) {
    n = sz(r);

    vector <vector <int> > g(n);
    for (int i = 0; i < n * 3; i++) {
        if (!r[i % n]) {
            le[i] = (i - 1 >= 0 ? le[i - 1] : -1);
        } else {
            le[i] = i;
        }
    }

    for (int i = n * 3 - 1; i >= 0; i--) {
        if (r[i % n]) {
            ri[i] = ri[i + 1];
        } else {
            ri[i] = i;
        }
    }
}

int compare_plants(int x, int y) {
    if (le[x + n - 1] + 1 <= y && y <= ri[x + n]) {
        return -1;
    }
    if (le[x + n - 1] + 1 <= y + n && y + n <= ri[x + n]) {
        return -1;
    }
    if (le[x + n - 1] + 1 <= y + 2 * n && y + 2 * n <= ri[x + n]) {
        return -1;
    }

    if (le[y + n - 1] + 1 <= x && x <= ri[y + n]) {
        return 1;
    }
    if (le[y + n - 1] + 1 <= x + n && x + n <= ri[y + n]) {
        return 1;
    }
    if (le[y + n - 1] + 1 <= x + 2 * n && x + 2 * n <= ri[y + n]) {
        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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 48 ms 4032 KB Output is correct
7 Correct 54 ms 5880 KB Output is correct
8 Correct 81 ms 16460 KB Output is correct
9 Correct 77 ms 16488 KB Output is correct
10 Correct 79 ms 16480 KB Output is correct
11 Correct 106 ms 16444 KB Output is correct
12 Correct 79 ms 16488 KB Output is correct
13 Correct 77 ms 16484 KB Output is correct
14 Correct 73 ms 16500 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 1 ms 308 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 1 ms 308 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 288 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 316 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 312 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 48 ms 4032 KB Output is correct
7 Correct 54 ms 5880 KB Output is correct
8 Correct 81 ms 16460 KB Output is correct
9 Correct 77 ms 16488 KB Output is correct
10 Correct 79 ms 16480 KB Output is correct
11 Correct 106 ms 16444 KB Output is correct
12 Correct 79 ms 16488 KB Output is correct
13 Correct 77 ms 16484 KB Output is correct
14 Correct 73 ms 16500 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Incorrect 1 ms 308 KB Output isn't correct
18 Halted 0 ms 0 KB -