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;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
using int64 = long long;
using ld = long double;
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
vector<int> psum;
int n = -1;
void init(int k, vector<int> r) {
assert(k == 2);
n = r.size();
r.insert(r.end(), r.begin(), r.end());
psum.resize(2 * n + 1, 0);
for (int i = 0; i < 2 * n; i++) {
psum[i + 1] = psum[i] + r[i];
}
}
int compare_plants(int x, int y) {
if (x > y) swap(x, y);
auto get = [&](const int l, const int r) {
return psum[r + 1] - psum[l];
};
const int dist1 = y - x;
const int dist2 = x + n - y;
if (get(x, y - 1) == 0 or get(y, n + x - 1) == dist2) {
return 1;
} else if (get(x, y - 1) == dist1 or get(y, n + x - 1) == 0) {
return -1;
} else {
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... |