# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420396 | idk321 | Comparing Plants (IOI20_plants) | C++17 | 93 ms | 8668 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 <bits/stdc++.h>
using namespace std;
int k;
vector<int> r;
vector<int> prefR;
int n;
int getSum(int from, int to)
{
int res = prefR[to + 1];
res -= prefR[from];
return res;
}
void init(int K, std::vector<int> R) {
k = K;
r = R;
n = r.size();
prefR.resize(r.size() + 1);
for (int i = 1; i <= r.size(); i++)
{
prefR[i] = r[i - 1];
prefR[i] += prefR[i - 1];
}
return;
}
int compare_plants(int x, int y) {
if (k == 2)
{
if (getSum(x, y - 1) == (y - x)) return -1;
if (getSum(x, y - 1) == 0) return 1;
int sum1 = getSum(y, n -1);
if (x != 0) sum1 += getSum(0, x - 1);
if (sum1 == (n - y) + x) return 1;
if (sum1 == 0) return -1;
return 0;
}
return 0;
}
Compilation message (stderr)
# | 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... |