#include "bits/stdc++.h"
#include "plants.h"
#define MAXN 200005
using namespace std;
int pref[MAXN];
int h[MAXN];
int n;
void init(int k, vector<int> r) {
n = r.size();
r.insert(r.begin() + 0, -1);
for (int height = n; height >= 1; height--) {
vector<int> zeroes;
pref[0] = 0;
for (int i = 1; i <= n; i++) {
pref[i] = pref[i-1];
if (r[i] == 0) {
pref[i]++;
zeroes.push_back(i);
}
}
int z = -1;
for (int x : zeroes) {
if (x-k+1 > 0) {
if (pref[x-1] - pref[x-k] == 0) {
z = x;
break;
}
} else {
if (pref[x-1] == 0 && pref[n] - pref[x-k+n] == 0) {
z = x;
break;
}
}
}
r[z] = INT_MAX;
h[z] = height;
for (int i = z-k+1; i < z; i++) {
if (i >= 1) r[i]--;
else r[i + n]--;
}
}
return;
}
int compare_plants(int x, int y) {
if (h[x+1] > h[y+1]) return 1;
else return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
112 ms |
5200 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
109 ms |
5204 KB |
Output is correct |
11 |
Correct |
110 ms |
5200 KB |
Output is correct |
12 |
Correct |
114 ms |
5204 KB |
Output is correct |
13 |
Correct |
116 ms |
5112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
112 ms |
5200 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
109 ms |
5204 KB |
Output is correct |
11 |
Correct |
110 ms |
5200 KB |
Output is correct |
12 |
Correct |
114 ms |
5204 KB |
Output is correct |
13 |
Correct |
116 ms |
5112 KB |
Output is correct |
14 |
Correct |
1179 ms |
5592 KB |
Output is correct |
15 |
Execution timed out |
4056 ms |
9796 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
44 ms |
4952 KB |
Output is correct |
4 |
Execution timed out |
4075 ms |
8868 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |