Submission #395040

# Submission time Handle Problem Language Result Execution time Memory
395040 2021-04-27T16:25:10 Z snasibov05 Comparing Plants (IOI20_plants) C++14
0 / 100
62 ms 3152 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 > v[i][j] + i) {
                l = j+1;
                break;
            }
        }

        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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 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 0 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 0 ms 204 KB Output is correct
3 Incorrect 62 ms 3152 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 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 -