제출 #429304

#제출 시각아이디문제언어결과실행 시간메모리
429304pere_gil슈퍼트리 잇기 (IOI20_supertrees)C++14
21 / 100
271 ms24060 KiB
#include "supertrees.h" #include "bits/stdc++.h" using namespace std; int p[1005]; void init(int n){ for(int i=0;i<n;i++) p[i]=i; } int find_set(int n){ return (p[n]==n) ? n : p[n]=find_set(p[n]); } bool same_set(int a, int b){ return find_set(a)==find_set(b); } void union_set(int a, int b){ if(!same_set(a,b)) p[find_set(a)]=find_set(b); } void form_group(vector<int> &g, vector<vector<int> > &v){ for(int i=1;i<g.size();i++) v[g[i]][g[i-1]]=v[g[i-1]][g[i]]=1; } int construct(vector<vector<int> > v){ int n=v.size(); init(n); for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(v[i][j]) union_set(i,j); vector<vector<int> > g(n); for(int i=0;i<n;i++) g[find_set(i)].push_back(i); /* printf("Groups are:\n"); for(int i=0;i<n;i++){ if(g[i].size()==0) continue; printf("%d: ",i); for(int j=0;j<g[i].size();j++) printf("%d ",g[i][j]); printf("\n"); } */ for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(same_set(i,j) && v[i][j]==0) return 0; vector<vector<int> > ans(n,vector<int> (n,0)); for(int i=0;i<n;i++) form_group(g[i],ans); build(ans); return 1; }

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

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