#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 400005;
#define REP(i,n) for(int i=0;i<(n);i++)
#define eb emplace_back
#define pb push_back
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
const int INF = 0x3f3f3f3f;
int n,k;
int a[maxn];
vector<int> r;
void init(int _k, std::vector<int> _r) {
k=_k;
n = _r.size();
r = _r;
REP(i,n) r.pb(r[i]);
int R = SZ(r);
bool type = 0;
for(int i=SZ(r)-1;i>=0;i--){
if(r[i]==type){
a[i]=R;
}
else{
R=i+1;
a[i]=R;
type = r[i];
}
}
}
int compare_plants(int x, int y) {
int flag = 1;
if(x>y) swap(x,y),flag = -1;
if(a[x]>=y){
if(r[x]==1){
return -flag;
}
else return flag;
}
if(a[y]>=x+n){
if(r[y]==1){
return flag;
}
else return -flag;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
64 ms |
3192 KB |
Output is correct |
7 |
Correct |
82 ms |
3676 KB |
Output is correct |
8 |
Correct |
108 ms |
7400 KB |
Output is correct |
9 |
Correct |
108 ms |
7400 KB |
Output is correct |
10 |
Correct |
115 ms |
7400 KB |
Output is correct |
11 |
Correct |
113 ms |
7400 KB |
Output is correct |
12 |
Correct |
108 ms |
7432 KB |
Output is correct |
13 |
Correct |
102 ms |
7404 KB |
Output is correct |
14 |
Correct |
104 ms |
7400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
64 ms |
3192 KB |
Output is correct |
7 |
Correct |
82 ms |
3676 KB |
Output is correct |
8 |
Correct |
108 ms |
7400 KB |
Output is correct |
9 |
Correct |
108 ms |
7400 KB |
Output is correct |
10 |
Correct |
115 ms |
7400 KB |
Output is correct |
11 |
Correct |
113 ms |
7400 KB |
Output is correct |
12 |
Correct |
108 ms |
7432 KB |
Output is correct |
13 |
Correct |
102 ms |
7404 KB |
Output is correct |
14 |
Correct |
104 ms |
7400 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
1 ms |
256 KB |
Output is correct |
17 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |