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>
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define ef emplace_front
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define F first
#define S second
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
int n;
vector<int> r;
vector<int> rg, rs;
void init(int k, vector<int> _r){
r = _r;
n = r.size();
assert(k == 2);
for(int i = 0; i < n; i++) r.eb(r[i]);
rg.resize(n);
rs.resize(n);
for(int i = 2 * n - 2; i >= 0; i--){
if(r[i] == 0) rg[i % n] = rg[(i + 1) % n] + 1;
else rs[i % n] = rs[(i + 1) % n] + 1;
}
}
int compare_plants(int x, int y){
// x < y
// x --> y
if(x + rg[x] >= y) return 1;
if(x + rs[x] >= y) return -1;
// y --> x
if(y + rg[y] >= x + n) return -1;
if(y + rs[y] >= x + n) return 1;
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... |