제출 #1057041

#제출 시각아이디문제언어결과실행 시간메모리
1057041aufan슈퍼트리 잇기 (IOI20_supertrees)C++17
40 / 100
108 ms24148 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int>> p) { int n = p.size(); vector<int> par(n); vector<vector<int>> ans(n, vector<int>(n)); iota(par.begin(), par.end(), 0); for (int i = 0; i < n; i++) { if (par[i] != i) continue; for (int j = i + 1; j < n; j++) { if (p[i][j] == 1) { par[j] = i; ans[i][j] = ans[j][i] = 1; } } } vector<int> par2(n); iota(par2.begin(), par2.end(), 0); for (int i = 0; i < n; i++) { if (par[i] != i || par2[i] != i) continue; int k = i; for (int j = i + 1; j < n; j++) { if (par[j] != j || par2[j] != j) continue; if (p[k][j] == 2) { par2[j] = i; ans[k][j] = ans[j][k] = 1; k = j; } } if (ans[i][k]) return 0; if (k == i) continue; ans[k][i] = ans[i][k] = 1; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (p[i][j] == 0) { if (par2[par[i]] == par2[par[j]]) { return 0; } } else if (p[i][j] == 1) { if (par[i] != par[j]) { return 0; } } else if (p[i][j] == 2) { if (par[i] == par[j] || par2[i] != par2[j]) { return 0; } } else if (p[i][j] == 3) { return 0; } } } build(ans); 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...