#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 |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
3 ms |
5040 KB |
Output is correct |
3 |
Correct |
2 ms |
5136 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
3 ms |
4956 KB |
Output is correct |
6 |
Correct |
48 ms |
8716 KB |
Output is correct |
7 |
Correct |
587 ms |
10832 KB |
Output is correct |
8 |
Execution timed out |
4038 ms |
17748 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5136 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Incorrect |
3 ms |
5140 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
3 ms |
5140 KB |
Output is correct |
4 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Output is correct |
2 |
Correct |
3 ms |
5040 KB |
Output is correct |
3 |
Correct |
2 ms |
5136 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
3 ms |
4956 KB |
Output is correct |
6 |
Correct |
48 ms |
8716 KB |
Output is correct |
7 |
Correct |
587 ms |
10832 KB |
Output is correct |
8 |
Execution timed out |
4038 ms |
17748 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |