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>
#pragma GCC optimize("O2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=200010, LOG=20;
int n, m, k, x, y, u, v, t, a, b, ans;
int A[MAXN], L[MAXN], R[MAXN];
void init(int k, vi _A){
assert(k==2);
n=SZ(_A);
for (int i=0; i<n; ++i) A[i]=_A[i];
for (int i=1; i<3*n; i++) if (A[(i-1)%n]) L[i%n]=L[(i-1)%n]+1;
for (int i=3*n; i; i--) if (!A[i%n]) R[i%n]=R[(i+1)%n]+1;
return;
}
int compare_plants(int x, int y){
if (y<=x+R[x] || (L[x]>x && n+x-L[x]<=y)) return 1;
if (y-L[y]<=x || (y+R[y]>=n && x<=y+R[y]-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... |