#include "plants.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
vector<int> muchii[200005];
int n,bigger[200005],smaller[200005],lastsmall[200005],lastbig[200005];
bool use[200005];
int dist(int a,int b)
{
return (b-a+n)%n;
}
void init(int k, std::vector<int> r)
{
n=r.size();
for(int i=0;i<n;i++)
{
lastbig[i]=-1;
lastsmall[i]=-1;
}
for(int i=0;i<n;i++)
{
if(r[i]==0)
{
int j=(i-1+n)%n;
while(r[j]==1)
{
lastsmall[j]=i;
j=(j-1+n)%n;
}
}
if(r[i]==1)
{
int j=(i-1+n)%n;
while(r[j]==0)
{
lastbig[j]=i;
j=(j-1+n)%n;
}
}
}
}
int compare_plants(int x, int y)
{
if(lastsmall[x]!=-1&&dist(x,y)+dist(y,lastsmall[x])==dist(x,lastsmall[x]))
return -1;
if(lastbig[x]!=-1&&dist(x,y)+dist(y,lastbig[x])==dist(x,lastbig[x]))
return 1;
if(lastsmall[y]!=-1&&dist(y,x)+dist(x,lastsmall[y])==dist(y,lastsmall[y]))
return 1;
if(lastbig[y]!=-1&&dist(y,x)+dist(x,lastbig[y])==dist(y,lastbig[y]))
return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8280 KB |
Output is correct |
6 |
Correct |
43 ms |
12056 KB |
Output is correct |
7 |
Correct |
47 ms |
13392 KB |
Output is correct |
8 |
Correct |
64 ms |
15000 KB |
Output is correct |
9 |
Correct |
64 ms |
14932 KB |
Output is correct |
10 |
Correct |
60 ms |
14988 KB |
Output is correct |
11 |
Correct |
63 ms |
15064 KB |
Output is correct |
12 |
Correct |
59 ms |
14960 KB |
Output is correct |
13 |
Correct |
57 ms |
14868 KB |
Output is correct |
14 |
Correct |
56 ms |
14980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8024 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8280 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8024 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8280 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8284 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8028 KB |
Output is correct |
4 |
Incorrect |
3 ms |
8284 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8284 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Incorrect |
2 ms |
8280 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8028 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
2 ms |
8280 KB |
Output is correct |
6 |
Correct |
43 ms |
12056 KB |
Output is correct |
7 |
Correct |
47 ms |
13392 KB |
Output is correct |
8 |
Correct |
64 ms |
15000 KB |
Output is correct |
9 |
Correct |
64 ms |
14932 KB |
Output is correct |
10 |
Correct |
60 ms |
14988 KB |
Output is correct |
11 |
Correct |
63 ms |
15064 KB |
Output is correct |
12 |
Correct |
59 ms |
14960 KB |
Output is correct |
13 |
Correct |
57 ms |
14868 KB |
Output is correct |
14 |
Correct |
56 ms |
14980 KB |
Output is correct |
15 |
Correct |
2 ms |
8024 KB |
Output is correct |
16 |
Correct |
2 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
2 ms |
8280 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |