Submission #395034

# Submission time Handle Problem Language Result Execution time Memory
395034 2021-04-27T16:14:46 Z snasibov05 Comparing Plants (IOI20_plants) C++14
0 / 100
61 ms 3192 KB
#include "plants.h"

#define pb push_back

using namespace std;

vector<int> h;

void init(int k, vector<int> r) {
    int n = r.size();
    h.resize(n);
    vector<int> v[k];
    for (int i = 0; i < n; ++i) {
        v[r[i]].pb(i);
    }

    int cur_h = 1;

    for (int i = k-1; i >= 0; --i) {
        int x = v[i].size();
        for (int j = 0; j < x; ++j) {
            v[i].pb(v[i][j] + n);
        }

        int l = 0;
        for (int j = 0; j < x; ++j) {
            auto it = lower_bound(v[i].begin() , v[i].end(), v[i][j]+1);
            if (*it > j + k - 1) l = j+1;
        }

        for (int j = l%x; j < l%x + x; ++j) {
            h[v[i][j]%n] = cur_h++;
        }
    }

}

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 0 ms 204 KB Output is correct
2 Correct 0 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 0 ms 204 KB Output is correct
2 Correct 0 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 61 ms 3192 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 -