제출 #1198983

#제출 시각아이디문제언어결과실행 시간메모리
1198983AMel0nConnecting Supertrees (IOI20_supertrees)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #include "supertrees.h" vector<int> par; int find(int n) { if (n == par[n]) return par[n]; return par[n] = find(par[n]); } void merge(int a, int b) { a = find(a); b = find(b); if (a == b) return ; par[b] = a; } int construct(vector<vector<int>> path) { int N = path.size(); par.resize(N); iota(all(par), 0); FOR(i, N) { for (int j = i + 1; j < N; j++) { if (path[i][j] > 0) merge(i, j); } } FOR(i, N) { for (int j = i + 1; j < N; j++) { if (!path[i][j] && find(i) == find(j)) return 0; } } vector<vector<int>> goofy(N); FOR(i, N) { goofy[find(i)].push_back(i); } vector<vector<int>> res(N, vector<int>(N)); // FOR(i, N) { // int parrr = find(i); // if (i != parrr) { // res[i][parrr] = 1; // res[parrr][i] = 1; // } // } FOR(i, N) { if (goofy[i].size() == 1) continue; if (goofy[i].size() == 2) return 0; int pr = -1; for(auto v: goofy[i]) { if (pr != -1) { res[v][pr] = 1; res[pr][v] = 1; } pr = v; } res[pr][goofy[i][0]] = 1; res[goofy[i][0]][pr] = 1; } build(res); return 1; } // signed main() { // cin.tie(0); ios::sync_with_stdio(false); // }
#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...