#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define N 200100
int n;
int pos[N], loc[N], cnt;
deque<int> R;
int info[200100][2];
void init2(vector<int> r) {
R.resize(n=r.size());
iota(R.begin(), R.end(), 0);
for(int i = 0; i < n; i++)
if(r[R.front()] == r[R.back()])
R.push_back(R.front()),R.pop_front();
else
break;
for(int i = 0; i < n; i++)
loc[R[i]] = i;
info[R.front()][0] = 0;
info[R.front()][1] = r[R.front()];
int prev = R.front();
R.pop_front();
for(int i = 1; i < n; i++) {
info[R.front()][1] = r[R.front()];
if(r[R.front()]!=r[prev]) {
info[R.front()][0] = ++cnt;
} else {
info[R.front()][0] = info[prev][0];
}
prev = R.front();
R.pop_front();
}
return;
}
void init(int k, vector<int> r) {
int x = k;
x = x+1;
init2(r);
}
int compare_plants(int x, int y) {
bool ans2=0;
if(loc[x]>loc[y])
ans2=1,swap(x,y);
if(loc[x]==0)
if(loc[y]>=loc[n-1])
ans2^=1,swap(x,y);
bool a = info[x][0] == info[y?y-1:n-1][0];
if(!a)
return 0;
return (ans2^info[x][1]?-1:1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
38 ms |
3056 KB |
Output isn't correct |
7 |
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 |
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 |
0 ms |
212 KB |
Output isn't correct |
3 |
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 |
Incorrect |
0 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 |
Incorrect |
1 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
38 ms |
3056 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |