# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078166 | mindiyak | Comparing Plants (IOI20_plants) | C++14 | 1 ms | 600 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 <iostream>
using namespace std;
#define F first
#define S second
vector<pair<int,int>> R;
vector<int> pos;
vector<int> m;
int N;
void init(int k, std::vector<int> r) {
int start = 0;
int len = 1;
pos.push_back(R.size());
N = r.size();
for(int l=1;l<r.size()*2;l++){
int i = l%r.size();
if(r[i] == r[start]){
len ++;
}else{
R.push_back({start,len});
start = i;
len = 1;
}
pos.push_back(R.size());
}
m = r;
return;
}
int compare_plants(int x, int y) {
int a=x;
// cerr << x << " " << y << endl;
a = pos[x];
if(m[R[a].F] == 0){
if(R[a].S == (y-x)) return 1;
}
a = pos[y];
if(m[R[a].F] == 1){
if(R[a].S == (N-y+x)) return 1;
}
a = pos[x];
if(m[R[a].F] == 1){
if(R[a].S == (y-x)) return -1;
}
a = pos[y];
if(m[R[a].F] == 0){
if(R[a].S == (N-y+x)) 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... |