제출 #543326

#제출 시각아이디문제언어결과실행 시간메모리
543326fuad27슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms304 KiB
#include "supertrees.h" #include <vector> #include "supertrees.h" #include<bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a;i<b;i++) using ll = long long; const int N = 1010; int n; ll p[N]; vector<vector<int>> res; ll find(ll u){return p[u] = ((p[u] == u)?u:find(p[u]));} void unite(ll u, ll v) { ll _u = find(u); ll _v = find(v); if(_u == _v)return; p[u] = v; res[u][v] = 1; } int construct(std::vector<std::vector<int>> g) { n = g.size(); iota(p, p+n, 0); res.assign(n, vector<int>(n,0)); rep(i, 0, n) { rep(j, 0, n) { if(g[i][j] == 1)unite(i, j); if(g[i][j] != g[j][i] or g[i][j] == 3)return 0; } } iota(p,p+n,0); rep(i, 0, n) { rep(j, 0, n) { if(g[i][j] == 2)unite(i, j); } } rep(i, 0, n) { rep(j, 0, n) { if(res[i][j] == 1 and g[i][j] == 0)return 0; } } build(res); 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...