제출 #540159

#제출 시각아이디문제언어결과실행 시간메모리
540159status_coding슈퍼트리 잇기 (IOI20_supertrees)C++14
46 / 100
196 ms22048 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int n; vector<vector<int>> ans; int viz[1005], viz2[1005]; void addEdge(int x, int y) { ans[x][y] = ans[y][x] = 1; } void solve(vector<int> &v, vector<vector<int>> &p) { vector<int> circle; for(int i : v) { if(!viz2[i]) { circle.push_back(i); viz2[i]=true; for(int j=0;j<n;j++) if(i != j && p[i][j] == 1) { addEdge(i ,j); viz2[j]=true; } } } if(circle.size() > 1) { for(int i=1; i<(int)circle.size(); i++) addEdge(circle[i-1], circle[i]); if(circle.size() > 2) addEdge(circle[0], circle.back()); } } int construct(vector<vector<int>> p) { n=p.size(); ans.resize(n); for(int i=0;i<n;i++) ans[i].resize(n); //cout<<ans.size()<<'\n'; for(int i=0;i<n;i++) for(int it : p[i]) if(it == 3 ) return 0; for(int i=0;i<n;i++) { if(!viz[i]) { vector<int> v; for(int j=0;j<n;j++) if(p[i][j]) { v.push_back(j); viz[j]=true; } for(int it : v) for(int it2 : v) if(p[it][it2] == 0) return 0; solve(v, p); } } 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...