제출 #565728

#제출 시각아이디문제언어결과실행 시간메모리
565728sidon슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms212 KiB
#include "supertrees.h" #include "bits/stdc++.h" using namespace std; int construct(vector<vector<int>> p) { int n = size(p); vector<vector<int>> g(n, vector<int> (n)); bool vis[n] {}; for(int r = 0; r < n; ++r) if(!vis[r]) { vector<int> c; vector<vector<int>> s; for(int i = r; i < n; ++i) if(!vis[i] && p[r][i]) { vis[i] = 1; c.push_back(i); } for(int i : c) { for(int j : c) if(!p[i][j]) return 0; if(vis[i]) { s.push_back({}); for(int j : c) if(p[i][j] < 2 && vis[j]) { vis[j] = 0; s.back().push_back(j); } } } for(auto &x : s) { for(auto &y : s) for(int i : x) for(int j : y) if((x[0] != y[0]) != (p[i][j] > 1)) return 0; for(int i = 1; i < int(size(x)); ++i) g[x[i-1]][x[i]] = g[x[i]][x[i-1]] = 1; } for(int i = 0; i < int(size(s)); ++i) { int u = s[i][0], v = s[(i+1) % size(s)][0]; g[u][v] = g[v][u] = 1; } for(int i : c) vis[i] = 1; } return build(g), 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...