#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int n, sv[MAXN];
void init(int k, vector<int> r) {
n = r.size();
for(int i = 0; i < n; i++){
sv[i+1] = sv[i]+r[i];
}
}
int compare_plants(int x, int y) {
bool swapped = false;
if(x>y){
swap(x, y);
swapped = true;
}
if(sv[y]-sv[x] == y-x){ //eh tudo 1, x so cresce ate chegar no y
if(swapped) return 1;
return -1;
}
if(sv[y]-sv[x] == 0){ //eh tudo 0, x so decresce ate chegar no y
if(swapped) return -1;
return 1;
}
if(sv[n]-(sv[y]-sv[x]) == n-(y-x)){ //eh tudo 1, y so cresce ate chegar no x
if(swapped) return -1;
return 1;
}
if(sv[n]-(sv[y]-sv[x]) == 0){
if(swapped) return 1;
return -1;
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |