| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 622351 | happypotato | 식물 비교 (IOI20_plants) | C++17 | 1 ms | 212 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;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
vector<int> r;
int n, k;
int st;
void st1init();
void init(int K, vector<int> R) {
n = R.size(); k = K; r = R;
if (k == 2) {
st = 1;
st1init();
}
return;
}
vector<int> st1ps;
void st1init() {
st1ps.resize(n);
st1ps[0] = r[0];
for (int i = 1; i < n; i++) {
st1ps[i] = st1ps[i - 1] + r[i];
}
}
int st1psquery(int l, int r) {
if (l > r) return st1psquery(r, n - 1) + st1psquery(0, l);
return (st1ps[r] - (l == 0 ? 0 : st1ps[l - 1]));
}
int st1query(int l, int r) {
bool large = (l > r);
if (large) swap(l, r);
int ret1 = st1psquery(l - 1, r), ret2 = st1psquery(r, l - 1);
if (ret1 == r - l || ret2 == 0) return (large ? -1 : 1);
else if (ret1 == 0 || ret2 == n - r + l) return (large ? 1 : -1);
else return 0;
}
int compare_plants(int x, int y) {
if (st == 1) return st1query(x, y);
}
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... | ||||
