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>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1500 + 10, M = 30;
const ll mod = 998244353;
int g;
bool block[N][N], was[N], pred[N][N];
void initialize(int n){
g = n;
}
void dfs(int v){
was[v] = true;
for(int i = 0; i < g; i++){
if(was[i] || block[i][v] == true) continue;
dfs(i);
}
}
int hasEdge(int u, int v){
if(pred[u][v]) return block[u][v];
pred[u][v] = pred[v][u] = true;
block[u][v] = block[v][u] = true;
dfs(0);
int cnt = 0;
for(int i = 0; i < g; i++){
if(was[i]) cnt++;
was[i] = false;
}
if(cnt != g) block[u][v] = block[v][u] = false;
return 1 - block[u][v];
}
// int main(){
// int n;
// cin >> n;
// initialize(n);
// for(int i = 0, a, b; i < ((n + 1) * n) / 2; i++){
// cin >> a >> b;
// cout << hasEdge(a, b) << 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... |