제출 #377333

#제출 시각아이디문제언어결과실행 시간메모리
377333autumn_eel슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms364 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; struct UnionFind{ vector<int>par; UnionFind(int n){ par=vector<int>(n); rep(i,n)par[i]=i; } int find(int x){ return par[x]==x?x:par[x]=find(par[x]); } void unite(int x,int y){ x=find(x);y=find(y); par[x]=y; } bool same(int x,int y){ return find(x)==find(y); } }; static vector<int>v[2000]; int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } UnionFind uf(n); rep(i,n)rep(j,n){ if(p[i][j])uf.unite(i,j); } rep(i,n){ v[uf.find(i)].push_back(i); } rep(i,n)rep(j,n){ if(i==j)continue; if(uf.same(i,j)&&!p[i][j])return 0; } rep(i,n){ if(v[i].size()>1){ rep(j,v[i].size()-1){ answer[v[i][j]][v[i][j+1]]=1; answer[v[i][j+1]][v[i][j]]=1; } answer[v[i].front()][v[i].back()]=1; answer[v[i].back()][v[i].front()]=1; } } build(answer); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:4:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,n)for(int i=0;i<(n);i++)
      |                              ^
supertrees.cpp:47:4: note: in expansion of macro 'rep'
   47 |    rep(j,v[i].size()-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...