제출 #315573

#제출 시각아이디문제언어결과실행 시간메모리
315573tigicha슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include "supertrees.h" #include<bits/stdc++.h> using namespace std; const int N=1e3+5; int par[1005], ar[1005], a[1005][1005], ans[1005][1005], fix1[1005], n, fix[1005]; vector<long long>vec1[1005], vec[1005], v1; vector<vector<long long> >answer; long long parent(long long x){ if(par[x]==x) return x; return par[x]=parent(par[x]); } void dsu(long long x, long long y){ x=parent(x); y=parent(y); if(x==y) return; if(ar[x]<ar[y]) swap(x, y); par[y]=x; ar[x]+=ar[y]; } void rec(long long z){ for(long long i=0; i<vec1[z].size(); i++) for(long long j=i+1; j<vec1[z].size(); j++){ long long x=vec1[z][i]; long long y=vec1[z][j]; if(a[x][y]==1){ vec[x].push_back(y); vec[y].push_back(x); } } v1.clear(); for(long long i=0; i<vec1[z].size(); i++){ long long x=vec1[z][i]; if(fix[x]) continue; v1.push_back(x); fix1[x]=1; if(!fix[x]) for(long long j=0; j<vec[x].size(); i++){ fix[vec[x][j]]=x; ans[x][vec[x][j]]=1; ans[vec[x][j]][x]=1; } } if(v1.size()>1) for(long long i=0; i<v1.size(); i++){ ans[v1[i]][v1[(i+1)%v1.size()]]=1; ans[v1[(i+1)%v1.size()]][v1[i]]=1; } } bool check(){ for(long long i=1; i<=n; i++){ std::vector<long long> v2; for(long long j=1; j<=n; j++){ if(i==j) ans[i][i]=0; else{ if(a[i][j]==0 && parent(i)==parent(j)) return 0; if(!fix1[i] && !fix1[j] && a[i][j]==2 && fix[i]==fix[j]) return 0; } v2.push_back(ans[i][j]); } answer.push_back(v2); } return 1; } int construct(std::vector<std::vector<long long> > v){ n=v.size(); for(long long i=1; i<=n; i++){ par[i]=i; ar[i]=1; } for(long long i=1; i<=n; i++) for(long long j=1; j<=n; j++){ a[i][j]=v[i-1][j-1]; if(a[i][j]==3) return 0; if(a[i][j]!=0) dsu(i, j); } for(long long i=1; i<=n; i++) vec1[parent(i)].push_back(i); for(long long i=1; i<=n; i++){ rec(i); if(v1.size()==2 && a[v1[0]][v1[1]]==2) return 0; } if(!check()) return 0; build(answer); return 1; }

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

supertrees.cpp: In function 'void rec(long long int)':
supertrees.cpp:21:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(long long i=0; i<vec1[z].size(); i++)
      |                     ~^~~~~~~~~~~~~~~
supertrees.cpp:22:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(long long j=i+1; j<vec1[z].size(); j++){
      |                       ~^~~~~~~~~~~~~~~
supertrees.cpp:31:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(long long i=0; i<vec1[z].size(); i++){
      |                     ~^~~~~~~~~~~~~~~
supertrees.cpp:37:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(long long j=0; j<vec[x].size(); i++){
      |                      ~^~~~~~~~~~~~~~
supertrees.cpp:44:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(long long i=0; i<v1.size(); i++){
      |                     ~^~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<long long int> >)':
supertrees.cpp:83:8: error: could not convert 'answer' from 'vector<vector<long long int>>' to 'vector<vector<int>>'
   83 |  build(answer);
      |        ^~~~~~
      |        |
      |        vector<vector<long long int>>