# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421296 | JUANDI321 | Comparing Plants (IOI20_plants) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "plants.h"
#include <vector>
#include <iostream>
using namespace std;
int sumpf[200010];
void init(int k, vector<int> r)
{
sumpf[0] = 200010;
for(int i = 1; i<n; i++)
{
sumpf[i]=sumpf[i-1]+r[i];
if(r[i]==0)sumpf[i]--;
}
return;
}
int compare_plants(int x, int y) {
int dis = y-x+1;
if(sumpf[y]-sumpf[x-1] == dis)return 1;
if(sumpf[y]-sumpf[x-1] == -1*dis)return -1;
return 0;
}