// I can do all things through Christ who strengthens me
// Philippians 4:13
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(i, j, k) for (int i = j; i < (k); i++)
#define RREP(i, j, k) for (int i = j; i >= (k); i--)
template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005;
const int MAXN = 200005;
int n, k;
vi r;
int bad[MAXN];
bool vis[MAXN];
int h[MAXN];
void init(int _k, vi _r) {
k = _k; r = _r;
n = SZ(r);
REP (i, 0, n) {
if (r[i] == k - 1) {
REP (j, i + 1, i + k) {
bad[j % n]++;
}
}
}
REP (z, 0, n) {
int id = -1;
REP (i, 0, n) {
if (vis[i]) {
continue;
}
if (r[i] == k - 1 && !bad[i]) {
id = i;
break;
}
}
h[id] = z;
vis[id] = 1;
REP (j, id + 1, id + k) {
bad[j % n]--;
}
RREP (ti, id - 1, id - k + 1) {
int i = (ti + n) % n;
r[i]++;
if (r[i] == k - 1) {
REP (j, i + 1, i + k) {
bad[j % n]++;
}
}
}
}
return;
}
int compare_plants(int x, int y) {
return h[x] > h[y] ? 1 : -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
260 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
14 ms |
340 KB |
Output is correct |
7 |
Correct |
311 ms |
5044 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
12 ms |
424 KB |
Output is correct |
10 |
Correct |
306 ms |
5040 KB |
Output is correct |
11 |
Correct |
205 ms |
4940 KB |
Output is correct |
12 |
Correct |
207 ms |
5152 KB |
Output is correct |
13 |
Correct |
380 ms |
5044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
14 ms |
340 KB |
Output is correct |
7 |
Correct |
311 ms |
5044 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
12 ms |
424 KB |
Output is correct |
10 |
Correct |
306 ms |
5040 KB |
Output is correct |
11 |
Correct |
205 ms |
4940 KB |
Output is correct |
12 |
Correct |
207 ms |
5152 KB |
Output is correct |
13 |
Correct |
380 ms |
5044 KB |
Output is correct |
14 |
Correct |
2975 ms |
5680 KB |
Output is correct |
15 |
Execution timed out |
4038 ms |
10532 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
41 ms |
4816 KB |
Output is correct |
4 |
Execution timed out |
4022 ms |
8904 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
260 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |