# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302431 | arnold518 | Comparing Plants (IOI20_plants) | C++14 | 117 ms | 5880 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5;
int N, K, R[MAXN+10], P[MAXN+10];
vector<int> V;
void init(int _K, vector<int> _R)
{
K=_K; N=_R.size();
for(int i=0; i<N; i++) R[i]=_R[i];
for(int i=0; i<N; i++)
{
if(R[i]!=R[(i+1)%N]) P[(i+1)%N]++;
}
for(int i=1; i<N; i++) P[i]+=P[i-1];
return;
}
int compare_plants(int x, int y)
{
int ans=0;
if(P[y-1]-P[x]==0)
{
if(R[x]) return -1;
else return 1;
}
if((x==0 ? 0 : P[x-1])+P[N-1]-P[y]==0)
{
if(R[y]) return 1;
else return -1;
}
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... |