이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <game.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000009LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)
#define MN 1505
int nn;
int deg[MN];
bool used[MN][MN];
void initialize(int n){
nn = n;
F0R(i, n){ used[i][i] = true; deg[i] = n-1; }
}
void exp(int cn){
//cout << "exp " << cn << "\n";
F0R(i, nn){
if(!used[i][cn]){
//cout << i << " " << cn << " nec\n";
used[i][cn] = used[cn][i] = true;
--deg[i]; --deg[cn];
if(deg[i] == 1) exp(i);
return;
}
}
}
int hasEdge(int u, int v){
if(used[u][v])
return 1;
used[u][v] = used[v][u] = true;
--deg[u]; --deg[v];
if(deg[u] == 1){
exp(u);
}
if(deg[v] == 1){
exp(v);
}
return 0;
}
/*int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(0);
int n;
cin >> n;
initialize(n);
F0R(_, n*(n-1)/2){
int u, v;
cin >> u >> v;
cout << hasEdge(u, v) << endl;
cout.flush();
}
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... |