# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421311 | JUANDI321 | Comparing Plants (IOI20_plants) | C++17 | 1 ms | 204 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 <vector>
#include <iostream>
using namespace std;
int sumpf[200010], copyr[20010];
int n;
void init(int k, vector<int> r)
{
n = r.size();
sumpf[0] = 200010;
//cout<<sumpf[1]<<" ";
//copyr[0] = r[0];
for(int i = 1; i < r.size(); i++)
{
sumpf[i] = sumpf[i-1] + r[i-1];
if(r[i-1] == 0) sumpf[i]--;
copyr[i-1] = r[i-1];
// cout<<sumpf[i+1]<<" ";
}
//cout<<endl;
return;
}
int compare_plants(int x, int y) {
if(x == 0 && y == n-1)
{
if(copyr[n-1] == 1) return 1;
return -1;
}
int dis = y-x+1;
//cout<<dis<<endl;
//cout<<sumpf[y]-sumpf[x-1]<<endl;
int sum = sumpf[y] - sumpf[x-1];
if(x == 0)sum = sumpf[y];
if(sum == dis) return 1;
if(sum == -1 * dis) 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... |