Submission #433582

#TimeUsernameProblemLanguageResultExecution timeMemory
433582SAADConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1 ms332 KiB
#include <iostream> #include <math.h> #include <algorithm> #include <vector> #include <string.h> #include "supertrees.h" using namespace std; bool ok; int tree[10002] , n; vector<vector<int>> a; vector <int> x[1002]; int dfs( int idx , int lab ) { tree[idx] = lab; for (auto i : x[idx]) { if (tree[i] == lab) continue; if (tree[i] == -1) { dfs(i,lab); } else { ok = false; } } return 0; } int construct(vector<vector<int>> p) { n = (int)p.size(); ok = true; memset(tree,-1,sizeof(tree)); a = p; for (int i = 0; i < (int)a.size(); i++) { for (int j = 0; j < (int)a.size(); j++) { if (i == j) continue; if (p[i][j] != p[j][i] || p[i][i] != 1 ) return 0; a[i][j] = 0; if (p[i][j] == 1) { x[i].push_back(j); } } } for (int i = 0; i < n; i++) { if (tree[i] == -1) { dfs(i,i); if (!ok) return 0; } } for (int i = 0; i < n; i++) { a[i] = p[tree[i]]; a[i][i] = 0; } build(a); 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...