# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815431 | vjudge1 | 식물 비교 (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 <iostream>
#include <vector>
using namespace std;
int n, h;
void init(int k, vector<int> r)
{
n = r.size();
h = k;
}
int compare_plants(int x, int y)
{
int z = 0, i;
if (h == 2)
{
for (i = x; i < y; i++)
{
if (r[i] == 1)
z--;
else
z++;
}
if (z == y - x)
return 1;
if (z == x - y)
return -1;
z = 0;
for (i = y; i < x + n; i++)
{
if (r[i % n] == 1)
z--;
else
z++;
}
if (z == y - x)
return 1;
if (z == x - y)
return -1;
return 0;
}
return z;
}