제출 #348379

#제출 시각아이디문제언어결과실행 시간메모리
348379Chaska슈퍼트리 잇기 (IOI20_supertrees)C++17
19 / 100
313 ms28140 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> #define pb push_back using namespace std; vector<int> g[1005],s; bool vs[1005],y; void dfs(int u) { s.pb(u); vs[u] = true; for (int v : g[u]) if (!vs[v]) dfs(v); } int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } y= true; for (int i=0;i<n;i++) for (int j=0;j<n;j++) if (i!=j) if (p[i][j]==2) g[i].pb(j); for (int i=0;i<n;i++) if (!vs[i]) { s.clear(); dfs(i); int ss = s.size(); if (ss==1) { } else if (ss>2) { for (int j=0;j<ss-1;j++) { answer[s[j]][s[j+1]] = 1; answer[s[j+1]][s[j]] = 1; } if (ss>1) { answer[s[ss-1]][s[0]] = 1; answer[s[0]][s[ss-1]] = 1; } for (int u : s) { for (int v : s) { if (p[u][v]==0) y = false; } } } else { y = false; return 0; } } if (y) build(answer); if (y) return 1; else return 0; }
#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...