제출 #306299

#제출 시각아이디문제언어결과실행 시간메모리
306299andreiomd슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1232 ms1945620 KiB
#include "supertrees.h" #include <vector> using namespace std; const int NMAX = 1e3 + 1; int N; int roads[NMAX][NMAX]; vector < int > tree[NMAX], cycle[NMAX]; bool Edge[NMAX][NMAX]; vector < int > line; vector < vector < int > > ans; int Id_tree[NMAX]; static inline void Add_Edge (int X, int Y) { Edge[X][Y] = Edge[Y][X] = 1; return; } static inline void DFS (int Node, int Father, int Id) { Id_tree[Id] = Id; for(auto it : tree[Node]) if(it != Father) Add_Edge(Node, it), DFS(it, Node, Id); return; } static inline void Build_trees () { for(int i = 1; i <= N; ++i) if(!tree[i].empty()) DFS(i, -1, i); return; } static inline void Solve () { Build_trees(); return; } static inline void Reconstruct () { ans.resize(N); for(int i = 1; i <= N; ++i) { line.resize(N); for(int j = 1; j <= N; ++j) line[j - 1] = Edge[i][j]; line.shrink_to_fit(); ans[i - 1] = line; } ans.shrink_to_fit(); return; } int construct (vector < vector < int > > p) { N = (int)p.size(); for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) { roads[i + 1][j + 1] = p[i][j]; if(i == j) continue; if(p[i][j] == 1) tree[i + 1].push_back(j + 1); else if(p[i][j] == 2) cycle[i + 1].push_back(j + 1); else if(p[i][j] == 3) return 0; } Solve(); Reconstruct(); 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...