Submission #302046

# Submission time Handle Problem Language Result Execution time Memory
302046 2020-09-18T11:41:38 Z VEGAnn Comparing Plants (IOI20_plants) C++14
14 / 100
4000 ms 5240 KB
#include "plants.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
const int N = 200100;
const int oo = 2e9;
vector<int> vc;
int per[N];

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

    assert(2 * k > n);

    for (int it = n - 1; it >= 0; it--){
        vc.clear();

        for (int i = 0; i < n; i++)
            if (r[i] == 0)
                vc.PB(i);

//        for (int i = 0; i < n; i++)
//            cerr << r[i] << " ";
//        cerr << '\n';

        assert(sz(vc) > 0);

        int cand = -1;

        for (int it = 0; it < sz(vc); it++){
            int cur = vc[it];
            int pre = vc[(it + sz(vc) - 1) % sz(vc)];

            if (pre < cur){
                if (pre - cur + n < k){
                    cand = cur;
                    break;
                }
            } else {
                if (pre - cur < k){
                    cand = cur;
                    break;
                }
            }
        }

        per[cand] = it;
        r[cand] = oo;

        for (int i = 1, loc = cand; i < k; i++){
            loc = (loc + n - 1) % n;

            r[loc]--;
        }
    }

    return;
}

int compare_plants(int x, int y) {
    return (per[x] > per[y] ? 1 : -1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 512 KB Execution killed with signal 11
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 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 253 ms 3352 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 10 ms 384 KB Output is correct
10 Correct 253 ms 3192 KB Output is correct
11 Correct 210 ms 3192 KB Output is correct
12 Correct 210 ms 3476 KB Output is correct
13 Correct 282 ms 3320 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 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 253 ms 3352 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 10 ms 384 KB Output is correct
10 Correct 253 ms 3192 KB Output is correct
11 Correct 210 ms 3192 KB Output is correct
12 Correct 210 ms 3476 KB Output is correct
13 Correct 282 ms 3320 KB Output is correct
14 Correct 2385 ms 3580 KB Output is correct
15 Execution timed out 4045 ms 5240 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 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 Runtime error 1 ms 512 KB Execution killed with signal 11
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 Runtime error 1 ms 640 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 512 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -