#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
vector<int> a, pre, dp1, dp2;
int n, k;
void init(int _k, vector<int> r) {
k = _k;
n = r.size();
pre.resize(n * 3);
dp1.resize(n * 3);
dp2.resize(n * 3);
for(int i = 0; i < 3; i++) {
a.in(a.end(), all(r));
}
int ls1 = -1, ls2= -1;
for(int i = n * 3 - 1; i >= 0; i--) {
if(a[i] == 0) {
if(ls1 != -1 && ls1 - i < k) dp1[i] = dp1[ls1];
else dp1[i] = i;
} else if(a[i] == k - 1) {
if(ls2 != -1 && ls2 - i < k) dp2[i] = dp2[ls2];
else dp2[i] = i;
}
}
}
int compare_plants(int x, int y) {
if(x < y) {
if(a[x] == 0 && dp1[x] + k - 1 >= y) return 1;
if(a[x] == k - 1 && dp2[x] + k - 1 >= y) return -1;
if(a[y] == 0 && dp1[y] + k - 1 >= x + n) return -1;
if(a[y] == k - 1 && dp2[y] + k - 1 >= x + n) return 1;
} else {
if(a[x] == 0 && dp1[x] + k - 1 >= y + n) return 1;
if(a[x] == k - 1 && dp2[x] + k - 1 >= y + n) return -1;
if(a[y] == 0 && dp1[y] + k - 1 >= x) return -1;
if(a[y] == k - 1 && dp2[y] + k - 1 >= x) return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
228 KB |
Output isn't correct |
3 |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |