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 F first
#define S second
vector<pair<int,int>> v, d;
int n;
void init(int p, vector<int> r) {
n = r.size();
int s = 0; for(;r[s]; s++); s++;
v.resize(n);
d.resize(n);
int b = s;
int k = 0;
for(int i = 0; i < n; i++) {
v[(s+i)%n] = {b, k++};
if(r[(s+i)%n] == 0) b = s+i+1, k = 0;
}
s = 0; for(;r[s]-1; s++); s++;
b = s;
k = 0;
for(int i = 0; i < n; i++) {
d[(s+i)%n] = {b, k++};
if(r[(s+i)%n]) b = s+i+1, k = 0;
}
}
int compare_plants(int x, int y) {
if(v[x].F != v[y].F) {
if(d[x].F != d[y].F) return 0;
if(d[x].S > d[y].S) return -1;
return 1;
}
if(v[x].S > v[y].S) return 1;
return -1;
}
# | 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... |