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 <bits/stdc++.h>
#include "game.h"
using namespace std;
vector<vector<int>> adjmatrix(0);
void initialize(int n)
{
adjmatrix.assign(n, vector<int> (n, -1));
for(int i = 0; i < n; i++)
{
adjmatrix[i][i] = 0;
}
}
void dfs(int i, vector<vector<int>>& adjmatrix, vector<bool>& visited)
{
visited[i] = true;
for(int j = 0; j < (int) adjmatrix[i].size(); j++)
{
if(!visited[j] && adjmatrix[i][j] != 0)
{
dfs(j, adjmatrix, visited);
}
}
}
int hasEdge(int u, int v)
{
int n = adjmatrix.size();
adjmatrix[u][v] = 0;
adjmatrix[v][u] = 0;
vector<bool> visited(n, false);
dfs(0, adjmatrix, visited);
if(find(visited.begin(), visited.end(), false) != visited.end())
{
adjmatrix[u][v] = 1;
adjmatrix[v][u] = 1;
return 1;
}
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... |