제출 #431350

#제출 시각아이디문제언어결과실행 시간메모리
431350MOUF_MAHMALAT슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms204 KiB
#include "supertrees.h" #include<bits/stdc++.h> using namespace std; typedef int ll; vector<vector<ll> >v,w; vector<pair<ll,ll> >op; ll n,p[1009],id[1009]; ll gp(ll z) { if(p[z]==z) return z; return p[z]=gp(p[z]); } void mrg(ll x,ll y,ll k) { if(w[y].size()>w[x].size()) swap(x,y); p[y]=x; if(k==0) return; for(auto z:w[y]) w[x].push_back(z); id[x]=k; } int construct(vector<vector<int> > pp) { n=pp.size(); v.resize(n); w.resize(n); for(ll i=0; i<n; i++) v[i].resize(n); for(ll i=0; i<n; i++) p[i]=i,w[i].push_back(i); for(ll i=0; i<n; i++) for(ll j=0; j<n; j++) { if(pp[i][j]<2) continue; ll x=gp(i),y=gp(j); if(x==y) continue; if(id[x]*id[y]==6) return 0; mrg(x,y,pp[i][j]); } for(ll i=0; i<n; i++) if(p[i]==i) { if(id[i]==3) { if(w[i].size()<4) return 0; for(ll j=0; j<w[i].size()-1; j++) op.push_back({w[i][j],w[i][j+1]}); op.push_back({w[i][0],w[i].back()}); op.push_back({w[i][1],w[i].back()}); } else if(id[i]==2) { if(w[i].size()<3) return 0; for(ll j=0; j<w[i].size()-1; j++) op.push_back({w[i][j],w[i][j+1]}); op.push_back({w[i][0],w[i].back()}); } } for(ll i=0; i<n; i++) for(ll j=0; j<n; j++) { if(pp[i][j]!=1) continue; ll x=gp(x),y=gp(y); if(w[x].size()>1&&w[y].size()>1) return 0; mrg(x,y,0); op.push_back({i,j}); } for(ll i=0;i<n;i++) for(ll j=0;j<n;j++) { if(pp[i][j]) continue; ll x=gp(i),y=gp(j); if(x==y) return 0; } for(auto z:op) v[z.first][z.second]=v[z.second][z.first]=1; build(v); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:56:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                 for(ll j=0; j<w[i].size()-1; j++)
      |                             ~^~~~~~~~~~~~~~
supertrees.cpp:65:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |                 for(ll j=0; j<w[i].size()-1; j++)
      |                             ~^~~~~~~~~~~~~~
supertrees.cpp:12:16: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |     return p[z]=gp(p[z]);
      |            ~~~~^~~~~~~~~
supertrees.cpp:75:24: note: 'y' was declared here
   75 |             ll x=gp(x),y=gp(y);
      |                        ^
supertrees.cpp:12:16: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |     return p[z]=gp(p[z]);
      |            ~~~~^~~~~~~~~
supertrees.cpp:75:16: note: 'x' was declared here
   75 |             ll x=gp(x),y=gp(y);
      |                ^
#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...