#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5;
int N, K, R[MAXN+10];
vector<int> V;
void init(int _K, vector<int> _R)
{
K=_K; N=_R.size();
for(int i=0; i<N; i++) R[i]=_R[i];
for(int i=0; i<N; i++)
{
if(R[i]!=R[(i+1)%N]) V.push_back(i);
}
for(int i=0; i<N; i++)
{
if(R[i]!=R[(i+1)%N]) V.push_back(i+N);
}
for(int i=0; i<N; i++)
{
if(R[i]!=R[(i+1)%N]) V.push_back(i+N+N);
}
return;
}
int compare_plants(int x, int y)
{
int ans=0;
if(*lower_bound(V.begin(), V.end(), x+1)==*lower_bound(V.begin(), V.end(), y))
{
if(R[x]) return -1;
else return 1;
}
x+=N;
swap(x, y);
if(*lower_bound(V.begin(), V.end(), x+1)==*lower_bound(V.begin(), V.end(), y))
{
if(R[x%N]) return 1;
else return -1;
}
return 0;
}
Compilation message
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:37:6: warning: unused variable 'ans' [-Wunused-variable]
37 | int ans=0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |