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;
const int N=200100;
int n,vis[N];
vector<int> ma[N];
void init(int k, std::vector<int> r) {
n=r.size();
for(int i=0;i<n;i++)
{
int j=(i+1)%n;
if(r[i]==0)
{
// j < i
ma[j].push_back(i);
}
else
{
// i < j
ma[i].push_back(j);
}
}
}
void dfs(int x)
{
vis[x]=1;
for(auto y:ma[x])
{
if(!vis[y])
{
dfs(y);
}
}
}
int compare_plants(int x, int y){
for(int i=0;i<n;i++)vis[i]=0;
dfs(x);
if(vis[y])
{
return -1;
}
else
{
for(int i=0;i<n;i++)vis[i]=0;
dfs(y);
if(vis[x])
{
return 1;
}
else
{
return 0;
}
}
// if(cp[x]==cp[y])
// {
// if(od[x]==od[y])return 0;
// return ((od[x]<od[y])?-1:1);
// }
// else
// 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... |