제출 #792043

#제출 시각아이디문제언어결과실행 시간메모리
792043mousebeaver슈퍼트리 잇기 (IOI20_supertrees)C++14
21 / 100
180 ms24024 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int>> p) { bool sub1 = true; int n = p.size(); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] != 1) { sub1 = false; } } } if(sub1) { vector<vector<int>> adjmatrix(n, vector<int> (n, 0)); for(int i = 0; i < n-1; i++) { adjmatrix[i][i+1] = 1; adjmatrix[i+1][i] = 1; } build(adjmatrix); return 1; } //sub2 vector<vector<int>> adjmatrix(n, vector<int> (n, 0)); vector<bool> used(n, false); for(int i = 0; i < n; i++) { if(!used[i]) { vector<int> nodes(0); for(int j = 0; j < n; j++) { if(p[i][j] == 1) { nodes.push_back(j); used[j] = true; } } for(int i : nodes) { if(count(p[i].begin(), p[i].end(), 1) != (int) nodes.size()) { return 0; } for(int j : nodes) { if(p[i][j] != 1) { return 0; } } } for(int i = 0; i < (int) nodes.size()-1; i++) { adjmatrix[nodes[i]][nodes[i+1]] = 1; adjmatrix[nodes[i+1]][nodes[i]] = 1; } } } build(adjmatrix); 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...