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 <iostream>
using namespace std;
#define len(a) ((int)(a).size())
vector<int> p, m;
void init(int k, vector<int> r) {
p.resize(len(r));
m.resize(len(r));
for(int i = 0, pr, now; i < 2 * len(r); i++){
now = i % len(r);
pr = (now == 0) ? len(r) - 1 : now - 1;
p[now] = m[now] = now;
if(r[pr] == 0){
p[now] = p[pr];
}
else {
m[now] = m[pr];
}
}
for(int i = 0; i < len(p); i++){
cout << p[i] << " ";
}
cout << endl;
for(int i = 0; i < len(m); i++){
cout << m[i] << " ";
}
cout << endl;
}
int compare_plants(int x, int y) {
if(x < y){
if(p[x] > x && p[x] <= y) return -1;
if(m[y] <= x && m[y] > y) return -1;
if(m[x] > x && m[x] <= y) return 1;
if(p[y] <= x && p[y] > y) return 1;
return 0;
}
if(p[x] <= y || p[x] > x) return -1;
if(m[y] > y && m[y] <= x) return -1;
if(m[x] <= y || m[x] > x) return 1;
if(p[y] > y && p[y] <= x) 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... |