Submission #1064843

# Submission time Handle Problem Language Result Execution time Memory
1064843 2024-08-18T18:24:55 Z Zicrus Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;

typedef long long ll;

ll n;
ll val;
vector<ll> a;

void init(int k, vector<int> r) {
    n = r.size();
    val = n;
    a = vector<ll>(n);
    while (val > 0) {
        ll id = 0;
        for (int i = n-1; i >= 0; i++) {
            if (r[i] == 0) {
                id = i;
                break;
            }
        }
        ll finId = id;
        for (int i = 1; i < k && id >= 0; i++) {
            id--;
            if (r[id] == 0) {
                i = 1;
                finId = id;
            }
        }
        a[finId] = val--;
        for (int i = 1; i < k; i++) {
            ll tId = (finId - i + n) % n;
            r[tId]--;
        }
        a[finId] = 1ll << 62ll;
    }
}

int compare_plants(int x, int y) {
	return a[x] > a[y] ? 1 : -1;
}

#ifdef TEST
#include "grader.cpp"
#endif
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -