제출 #300331

#제출 시각아이디문제언어결과실행 시간메모리
300331junseo슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms256 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rmin(r, x) r = min(r, x) #define rmax(r, x) r = max(r, x) #define ends ' ' #define endl '\n' #define fastio ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxn = 1e3 + 10; int n, pa[maxn]; bool chk[maxn]; vector<vector<int>> b; int fnd(int x) { return (pa[x] < 0 ? x : pa[x] = fnd(pa[x])); } void uni(int a, int b) { a = fnd(a), b = fnd(b); if(a == b) return; pa[a] = b; } int construct(vector<std::vector<int>> p) { memset(pa, -1, sizeof(pa)); n = p.size(); b.resize(n); for(int i = 0; i < n; ++i) b[i].resize(n); for(int i = 0; i < n; ++i) if(!chk[i]) { vector<int> v; for(int j = i + 1; j < n; ++j) if(p[i][j]) v.eb(j); if(v.size() < 2) return 0; chk[i] = true; int prev = i; for(auto& j : v) { chk[j] = true; uni(prev, j); b[prev][j] = b[j][prev] = 1; prev = j; } b[prev][i] = b[i][prev] = 1; } for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) { if(!p[i][j] && fnd(i) == fnd(j)) return 0; if(p[i][j] && fnd(i) != fnd(j)) return 0; } build(b); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...