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 "plants.h"
#include <bits/stdc++.h>
#ifdef LOCAL
#include "grader.cpp"
#endif // LOCAL
using namespace std;
const int N = 1e5 + 10;
int was[N];
vector<int> a, p;
void init(int K, vector<int> r) {
int k, n;
k = K;
a = r;
n = a.size();
p.resize(n);
for(int j = 0; j < n; ++j)
a[j] = k - 1 - a[j];
for(int i = n - 1; i >= 0; --i){
// cout << i << endl;
int pos = 0;
for(int j = 0; j < n; ++j)
if(a[j] == k - 1 && was[j] == 0)
pos = j, j += k - 1;
p[pos] = i;
was[pos] = 1;
for(int j = 1; j <= k - 1; ++j)
++a[(pos - j + n) % n];
// for(int i = 0; i < n; ++i)
// cout << a[i] << " ";
// cout << endl;
// for(int i = 0; i < n; ++i)
// cout << p[i] << " ";
// cout << endl;
}
}
int compare_plants(int x, int y) {
if(p[x] > p[y])
return 1;
else
return -1;
}
/*
4 3 2
0 1 1 2
0 2
1 2
1
-1
*/
# | 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... |