이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int32_t, int32_t> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 1500
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
int N;
int p[maxn], ncomp;
bool mat[maxn][maxn]; // nos
bool vis[maxn];
int fl(int x){
if (p[x] == x) return x;
return p[x] = fl(p[x]);
}
void initialize(int n) {
N = n;
}
bool dfs(int x, int tar){
if (x == tar) return 1;
if (vis[x]) return 0;
vis[x] = 1;
bool ans = 0;
FOR(i,0,N-1) if (!mat[i][x]) ans |= dfs(i, tar);
return ans;
}
int num[maxn];
int hasEdge(int u, int v) {
mat[u][v] = mat[v][u] = 1;
if (num[u] + num[v] < N - 2){
num[u]++; num[v]++;
return 0;
}
FOR(i,0,N-1) vis[i] = 0;
if (!dfs(u,v)){ // forced to connect
mat[u][v] = mat[v][u] = 0;
return 1;
}else{
num[u]++; num[v]++;
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... |