제출 #127323

#제출 시각아이디문제언어결과실행 시간메모리
127323nxteru게임 (IOI14_game)C++14
컴파일 에러
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; struct UF{ int n,par[1505],rs[1505],sz[1505]; void ini(int x,int v){ n=x; for(int i=0;i<n;i++){ par[i]=i; if(i==v)rs[i]=0; else rs[i]=1; sz[i]=1; } } int find(int x){ if(par[x]==x)return x; return par[x]=find(par[x]); } void unit(int v,int u){ v=find(v); u=find(u); if(sz[v]<sz[u])swap(u,v); rs[v]+=rs[u]; par[u]=v; sz[v]+=sz[u]; } }; int n,par[1505],sz[1505]; UF p[1505]; bool rt[1505]; vector<int>rts; int find(int x){ if(par[x]==x)return x; return par[x]=find(par[x]); } void unit(int v,int u){ v=find(v); u=find(u); if(sz[v]<sz[u])swap(u,v); for(int i=0;i<rts.size();i++)p[v].rs[rts[i]]+=p[u].rs[rts[i]]; par[u]=v; sz[v]+=sz[u]; rt[u]=false; } void initialize(int N) { n=N; for(int i=0;i<n;i++)par[i]=i,p[i].ini(n,i),sz[i]=1,rt[i]=true; } int hasEdge(int u, int v) { u=find(u); v=find(v); if(u==v)return 1; p[u].rs[v]--; p[v].rs[u]--; if(p[u].rs[v]>0)return 0; else{ rts.clear(); for(int i=0;i<n;i++)if(rt[i])rts.PB(i); for(int i=0;i<rts.size();i++)p[rts[i]].unit(v,u); unit(v,u); return 1; } }

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

game.cpp: In function 'void unit(int, int)':
game.cpp:40:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<rts.size();i++)p[v].rs[rts[i]]+=p[u].rs[rts[i]];
              ~^~~~~~~~~~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:59:36: error: 'class std::vector<int>' has no member named 'PB'
   for(int i=0;i<n;i++)if(rt[i])rts.PB(i);
                                    ^~
game.cpp:60:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<rts.size();i++)p[rts[i]].unit(v,u);
               ~^~~~~~~~~~~