| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 300265 | marX | Comparing Plants (IOI20_plants) | C++17 | 4061 ms | 6028 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
using namespace std;
vector<int> xrank;
void init(int k, vector<int> r)
{
    int n = r.size();
    xrank.resize(n);
    vector<bool> used(n);
    int remaining = n;
    int pos = n;
    for (int i = 0; i < n; ++i, --remaining)
    {
        vector<int> current;
        for (int i = 0; i < n; ++i)
        {
            if (used[i])
                continue;
            if (r[i] == 0)
                current.push_back(i);
        }
        int start = 0;
        int max_diff = current[0] + n - current.back();
        for (int i = 1; i < current.size(); ++i)
        {
            int cur_diff = current[i] - current[i - 1];
            if (cur_diff > max_diff)
            {
                max_diff = cur_diff;
                start = i;
            }
        }
        if (current.empty())
            break;
        int u = current[start];
        used[u] = true;
        xrank[u] = pos--;
        for (int j = 1; j < k; ++j)
        {
            int t = (u - j + n) % n;
            r[t]--;
            // debug(t, u, r[t]);
        }
        // debug(i);
        // debug(current[start], current);
        // debug(used);
        // debug(r);
    }
    // debug(remaining);
    // if (remaining != 0)
    //     fin("FAIL!!!");
}
int compare_plants(int a, int b)
{
    return xrank[a] > xrank[b] ? +1 : -1;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
