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;
int n;
bool sub1;
vector<int> esq, dir;
void init(int k, vector<int> r) {
sub1 = k == 2;
n = r.size();
if(sub1){
esq = vector<int> (n);
dir = vector<int> (n);
int ini;
for(ini = 0; ini < n; ini++)
if(r[ini] == 1) break;
ini++;
ini %= n;
esq[ini] = 0;
for(int i = ini + 1; i != ini; i++, i %= n){
int ant = i - 1;
if(ant < 0) ant += n;
esq[i] = esq[ant] + 1;
if(r[ant] == 1) esq[i] = 0;
}
for(ini = 0; ini < n; ini++)
if(r[ini] == 0) break;
dir[ini] = 0;
for(int i = (ini + n - 1) % n; i != ini; i += n - 1, i %= n){
int nex = i + 1;
if(nex >= n) nex -= n;
dir[i] = dir[nex] + 1;
if(r[i] == 0) dir[i] = 0;
}
}
return;
}
int compare_plants(int x, int y) {
if(sub1){
if(x + dir[x] >= y) return 1;
if(y - esq[y] <= x) return -1;
return 0;
}
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... |