Submission #621161

#TimeUsernameProblemLanguageResultExecution timeMemory
621161Mr_Husanboy슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms212 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; struct DSU{ vector<int> parent, sz; void init(int n){ parent.resize(n), sz.resize(n); for(int i = 0; i < n; i ++) parent[i] = i, sz[i] = 1; } int get(int a){ return parent[a] == a ? a : parent[a] = get(parent[a]); } void unite(int a, int b){ a = get(a); b = get(b); if(a==b) return; if(sz[a] < sz[b]) swap(a,b); sz[a] += sz[b]; parent[b] = a; } }; int construct(vector<vector<int>> p) { return 0; int n = p.size(); vector<vector<int>> b(n,vector<int> (n)); DSU t; t.init(n); for(int j = 0; j < n; j ++){ for(int i = 0; i < n; i ++){ if(i!=j && p[i][j]) t.unite(i,j); } } for(int i = 0; i < n; i ++){ for(int j = 0; j < n; j ++){ if(p[i][j] == 0 && t.get(i) == t.get(j)) return 0; } } vector<vector<int>> par(n); for(int i = 0; i < n; i ++){ par[t.get(i)].push_back(i); } for(int i = 0; i < n; i ++){ for(int j = 1; j < par[i].size(); j ++){ int u = par[i][j], v = par[i][j-1]; b[u][v] = b[v][u] = 1; } /* if(par[i].size() > 1){ int u = par[i][0], v = par[i].back(); b[u][v] = b[v][u] = 1; }*/ } build(b); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int j = 1; j < par[i].size(); j ++){
      |                        ~~^~~~~~~~~~~~~~~
#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...