Submission #1198911

#TimeUsernameProblemLanguageResultExecution timeMemory
1198911AMel0nConnecting Supertrees (IOI20_supertrees)C++20
21 / 100
120 ms22184 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>> res(N, vector<int>(N)); FOR(i, N) { int parrr = find(i); if (i != parrr) { res[i][parrr] = 1; res[parrr][i] = 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...