제출 #309463

#제출 시각아이디문제언어결과실행 시간메모리
309463pere_gil슈퍼트리 잇기 (IOI20_supertrees)C++17
21 / 100
273 ms26232 KiB
#include "bits/stdc++.h" #include "supertrees.h" using namespace std; int pos[1001]; void init(int n){ for(int i=0;i<n;i++) pos[i]=i; } int findset(int a){ if(pos[a]==a) return a; else return pos[a]=findset(pos[a]); } void unionset(int A, int B){ int a=findset(A); int b=findset(B); if(a!=b) pos[b]=a; } bool issameset(int a, int b){ if(findset(a)==findset(b)) return true; else return false; } int construct(std::vector<std::vector<int> > p) { int n = p.size(); std::vector<std::vector<int> > answer; init(n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==1) unionset(i,j); } } vector<int> ja[n]; for(int i=0;i<n;i++) ja[findset(i)].push_back(i); bool semamo=false; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(issameset(i,j) and p[i][j]==0) semamo=true; } } if(semamo) return 0; int res[n+1][n+1]; memset(res,0,sizeof(res)); for(int i=0;i<n;i++){ for(int j=1;j<ja[i].size();j++){ res[ ja[i][j] ] [ ja[i][j-1] ]=1; res[ ja[i][j-1] ] [ ja[i][j] ]=1; } } for (int i = 0; i < n; i++) { std::vector<int> row; for(int j=0;j<n;j++) row.push_back(res[i][j]); row.resize(n); answer.push_back(row); } build(answer); return 1; return 0; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int j=1;j<ja[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...