#include "plants.h"
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
int h,n,arr[200001];
void init(int k, std::vector<int> r)
{
h=k;
n=sz(r);
for (int i=0;i<n;i++)
{
if(r[i]!=k-1)arr[i]=0;
else arr[i]=k-1;
}
return;
}
int compare_plants(int x, int y)
{
if (arr[x]==0)
{
int g=h-1;
int f=x+1;
while(f<y && g>=0)
{
if (arr[f]==0)g=h-1;
f++;
g--;
}
if (f+1==y)return 1;
}
else
{
int g=h-1;
int f=x+1;
while(f<y && g>=0)
{
if (arr[f]==h-1)g=h-1;
f++;
g--;
}
if (f+1==y)return -1;
}
if (arr[y]==h-1)
{
int g=h-1;
int f=y+1;
while(f<n && g>=0)
{
if (arr[f]==h-1)g=h-1;
f++;
g--;
}
f=0;
while(f<x && g>=0)
{
if (arr[f]==h-1)g=h-1;
f++;
g--;
}
if (f+1==x)return 1;
}
else
{
int g=h-1;
int f=y+1;
while(f<n && g>=0)
{
if (arr[f]==0)g=h-1;
f++;
g--;
}
f=0;
while(f<x && g>=0)
{
if (arr[f]==0)g=h-1;
f++;
g--;
}
if (f+1==x)return -1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |