Submission #1071667

# Submission time Handle Problem Language Result Execution time Memory
1071667 2024-08-23T09:48:21 Z Ignut Comparing Plants (IOI20_plants) C++17
5 / 100
62 ms 7400 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int n, k;

vector<int> r;
vector<int> cntInRow;

void init(int K, vector<int> R) {
    n = R.size();
    k = K;
    r = R;
    for (int val : R) r.push_back(val);
    cntInRow.resize(2 * n);
    cntInRow[2 * n - 1] = 1;
    for (int i = 2 * n - 2; i >= 0; i --)
        cntInRow[i] = (r[i] == r[i + 1] ? cntInRow[i + 1] + 1 : 1);
}

int compare_plants(int x, int y) {
    if (k == 2) {
        if (x + cntInRow[x] >= y)
            return r[x] == 1 ? -1 : 1;
        if (y + cntInRow[y] - n >= x)
            return r[y] == 1 ? 1 : -1;
        return 0;
    }
    if (x + k - 1 >= y) {
        if (r[y] - r[x] > y - x) return 1;
        if (r[x] - r[y] > y - x) return -1;
    }
    if (y + k - 1 - n >= x) {
        if (r[x] - r[y] > x + n - y) return -1;
        if (r[y] - r[x] > x + n - y) return 1;
    }
    return 0;
}
# 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 30 ms 3044 KB Output is correct
7 Correct 35 ms 3616 KB Output is correct
8 Correct 47 ms 7236 KB Output is correct
9 Correct 62 ms 7400 KB Output is correct
10 Correct 47 ms 7400 KB Output is correct
11 Correct 47 ms 7236 KB Output is correct
12 Correct 48 ms 7236 KB Output is correct
13 Correct 53 ms 7396 KB Output is correct
14 Correct 45 ms 7232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 360 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 0 ms 344 KB Output is correct
2 Correct 0 ms 360 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 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 30 ms 3044 KB Output is correct
7 Correct 35 ms 3616 KB Output is correct
8 Correct 47 ms 7236 KB Output is correct
9 Correct 62 ms 7400 KB Output is correct
10 Correct 47 ms 7400 KB Output is correct
11 Correct 47 ms 7236 KB Output is correct
12 Correct 48 ms 7236 KB Output is correct
13 Correct 53 ms 7396 KB Output is correct
14 Correct 45 ms 7232 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 360 KB Output is correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Halted 0 ms 0 KB -