Submission #424500

#TimeUsernameProblemLanguageResultExecution timeMemory
424500MrFranchoConnecting Supertrees (IOI20_supertrees)C++14
11 / 100
434 ms24060 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1000; vector<vector<int>> connectedGroups; bool vis[MAXN]{}; int N; void DFS(int node, int cur, vector<vector<int>> &p) { connectedGroups[cur].push_back(node); vis[node] = true; for(int i = 0; i < N; i++) { if(i != node && p[node][i] == 1 && !vis[i]) DFS(i,cur,p); } } int construct(vector<vector<int>> p) { N = p.size(); vector<vector<int>> answer(N); for(int i = 0; i < N; i++) { answer[i].assign(N,0); for(int j = i+1; j < N; j++) { for(int k = j+1; k < N; k++) { if (p[i][k] == 1 && p[j][k] == 1 && p[i][j] != 1) return 0; } } } int c = 0; for (int i = 0; i < N; i++) { if(!vis[i]) { vector<int> emp; connectedGroups.push_back(emp); DFS(i,c,p); c++; } } /*for(int i = 0; i < connectedGroups.size(); i++) { cout << i << ":\n"; for(auto x: connectedGroups[i]) cout << x << endl; }*/ for(auto v : connectedGroups) { for(int i = 1; i < (int)v.size(); i++) { answer[v[0]][v[i]] = answer[v[i]][v[0]] = 1; } } build(answer); 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...