This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma once
#include "bits/stdc++.h"
using namespace std;
int N=1e9;
map<pair<int,int>,int>mp2;
map<pair<int,int>,bool>mp3;
vector<vector<int>>gr;
bool able(int x, int u, int v, vector<bool>&vis)
{
if(x==v)return 1;
vis[x]=1;
for(auto c:gr[x])
{
if(vis[c] || (x==u && c==v) || mp3[{u,v}])continue;
if(able(c,u,v,vis))return 1;
}
return 0;
}
void initialize(int n)
{
gr.resize(n);
for(int i=0; i<n; i++)
{
for(int j=0;j<n; j++)
{
if(i==j)continue;
gr[i].push_back(j);
}
}
return;
}
int hasEdge(int u, int v)
{
if(u>v)swap(u,v);
if(mp2[{u,v}])return mp2[{u,v}]%2;
vector<bool>vis((int)gr.size());
if((int)gr[u].size()==1 || (int)gr[v].size()==1 || !able(u,u,v,vis))
{
mp2[{u,v}]=1;
return 1;
}
mp2[{u,v}]=2;
mp3[{u,v}]=1;
// cout<<"1"<<endl;
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... |