Submission #406553

# Submission time Handle Problem Language Result Execution time Memory
406553 2021-05-17T17:35:51 Z snasibov05 Comparing Plants (IOI20_plants) C++14
14 / 100
4000 ms 9416 KB
#include "plants.h"
#include <queue>

#define pb push_back

using namespace std;

vector<int> h;

void init(int k, vector<int> r) {
    int n = r.size();
    int x = n;
    h.resize(n);

    for (int i = 0; i < n; ++i) {
        r.pb(r[i]);
    }

    for (int i = 0; i < n; ++i) {

        queue<int> q;

        for (int j = 0; j < n; ++j) {
            if (!q.empty() && q.front() < j - k + 1) q.pop();
            if (r[j] == 0) q.push(j);
        }

        int cur = 0;

        for (int j = n; j < 2*n; ++j) {
            if (!q.empty() && q.front() < j - k + 1) q.pop();
            if (r[j] == 0 && q.empty()){
                cur = j;
                break;
            }
            if (r[j] == 0) q.push(j);
        }

        h[cur%n] = x--;

        for (int j = cur; j > cur - k ; --j) {
            r[j]--;
            if (j >= n) r[j-n]--;
            else r[j+n]--;
        }
    }

}

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

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 7 ms 296 KB Output is correct
7 Correct 166 ms 5056 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 7 ms 396 KB Output is correct
10 Correct 167 ms 5060 KB Output is correct
11 Correct 184 ms 4932 KB Output is correct
12 Correct 155 ms 5200 KB Output is correct
13 Correct 176 ms 5060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 7 ms 296 KB Output is correct
7 Correct 166 ms 5056 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 7 ms 396 KB Output is correct
10 Correct 167 ms 5060 KB Output is correct
11 Correct 184 ms 4932 KB Output is correct
12 Correct 155 ms 5200 KB Output is correct
13 Correct 176 ms 5060 KB Output is correct
14 Correct 1595 ms 5508 KB Output is correct
15 Execution timed out 4062 ms 9416 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 79 ms 3024 KB Output is correct
4 Execution timed out 4041 ms 8748 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -