# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431515 | Hazem | Comparing Plants (IOI20_plants) | C++14 | 111 ms | 5736 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;
int k;
vector<int>a,pr;
void init(int K, std::vector<int> r) {
k = k;a = pr = r;
for(int i=1;i<a.size();i++)
pr[i] += pr[i-1];
return;
}
bool check(int x,int y){
if(y>x)
return (pr[y-1]-(x?pr[x-1]:0))==(y-x);
else
return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y);
}
bool check1(int x,int y){
if(y>x)
return (pr[y-1]-(x?pr[x-1]:0))==0;
else
return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==0;
}
int compare_plants(int x, int y) {
if(check(x,y)||check1(y,x))
return -1;
if(check(y,x)||check1(x,y))
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... |