#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> height(0);
void init(int k, vector<int> r)
{
int n = r.size();
height.assign(n, -1); //-1 = not already known
for(int nodes = 0; nodes < n; nodes++)
{
vector<int> candidates(0);
for(int i = 0; i < n; i++)
{
if(height[i] == -1 && r[i] == 0)
{
candidates.push_back(i);
}
}
int index = 0;
while(!(index == (int) candidates.size()-1 || candidates[index]+k-1 >= candidates.back()) ||
!(index == 0 || (candidates[index]+k-1)%n >= candidates[index-1]))
{
index++;
}
height[candidates[index]] = n-nodes;
for(int i = 0; i < k; i++)
{
int j = candidates[index]-i;
if(j < 0) j += n;
r[j]--;
}
}
//vector<int> test = height;
//int temp = 0;
}
int compare_plants(int x, int y)
{
if(height[x] > height[y])
{
return 1;
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
5 ms |
340 KB |
Output is correct |
7 |
Correct |
137 ms |
5104 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
5 ms |
340 KB |
Output is correct |
10 |
Correct |
135 ms |
4980 KB |
Output is correct |
11 |
Correct |
112 ms |
5004 KB |
Output is correct |
12 |
Correct |
115 ms |
5208 KB |
Output is correct |
13 |
Correct |
148 ms |
5092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
5 ms |
340 KB |
Output is correct |
7 |
Correct |
137 ms |
5104 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
5 ms |
340 KB |
Output is correct |
10 |
Correct |
135 ms |
4980 KB |
Output is correct |
11 |
Correct |
112 ms |
5004 KB |
Output is correct |
12 |
Correct |
115 ms |
5208 KB |
Output is correct |
13 |
Correct |
148 ms |
5092 KB |
Output is correct |
14 |
Correct |
1882 ms |
5488 KB |
Output is correct |
15 |
Execution timed out |
4051 ms |
8640 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 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 |
- |