#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
vector<int> r;
int n, k;
int st;
void st1init();
void init(int K, vector<int> R) {
n = R.size(); k = K; r = R;
if (k == 2) {
st = 1;
st1init();
}
return;
}
vector<int> st1ps;
void st1init() {
st1ps.resize(n);
st1ps[0] = r[0];
for (int i = 1; i < n; i++) {
st1ps[i] = st1ps[i - 1] + r[i];
}
}
int st1psquery(int l, int r) {
if (l > r) return st1psquery(l, n - 1) + st1psquery(0, r);
return (st1ps[r] - (l == 0 ? 0 : st1ps[l - 1]));
}
int st1query(int l, int r) {
bool large = (l > r);
if (large) swap(l, r);
int ret1 = st1psquery(l, r - 1), ret2 = st1psquery(r, (l == 0 ? n - 1 : l - 1));
if (ret1 == r - l || ret2 == 0) return (large ? 1 : -1);
else if (ret1 == 0 || ret2 == n - r + l) return (large ? -1 : 1);
else return 0;
}
int compare_plants(int x, int y) {
if (st == 1) return st1query(x, y);
}
Compilation message
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
43 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
57 ms |
3984 KB |
Output is correct |
7 |
Correct |
55 ms |
5508 KB |
Output is correct |
8 |
Correct |
79 ms |
8660 KB |
Output is correct |
9 |
Correct |
77 ms |
8668 KB |
Output is correct |
10 |
Correct |
71 ms |
8672 KB |
Output is correct |
11 |
Correct |
72 ms |
8652 KB |
Output is correct |
12 |
Correct |
69 ms |
8664 KB |
Output is correct |
13 |
Correct |
89 ms |
8664 KB |
Output is correct |
14 |
Correct |
62 ms |
8656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
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 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
5 |
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 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
57 ms |
3984 KB |
Output is correct |
7 |
Correct |
55 ms |
5508 KB |
Output is correct |
8 |
Correct |
79 ms |
8660 KB |
Output is correct |
9 |
Correct |
77 ms |
8668 KB |
Output is correct |
10 |
Correct |
71 ms |
8672 KB |
Output is correct |
11 |
Correct |
72 ms |
8652 KB |
Output is correct |
12 |
Correct |
69 ms |
8664 KB |
Output is correct |
13 |
Correct |
89 ms |
8664 KB |
Output is correct |
14 |
Correct |
62 ms |
8656 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Runtime error |
1 ms |
304 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |