Submission #120141

#TimeUsernameProblemLanguageResultExecution timeMemory
120141BoxworldWerewolf (IOI18_werewolf)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "werewolf.h" typedef vector<int> Vec; const int maxN=400100; Vec G[maxN]; int Fp[maxN],Fw[maxN],vis1[maxN],vis2[maxN],a[maxN]; int find1(int x){return x==Fp[x]?x:Fp[x]=find1(Fp[x]);} int find2(int x){return x==Fw[x]?x:Fw[x]=find2(Fw[x]);} void uni1(int x,int y){ int Fx=find1(x),Fy=find1(y); if(Fx==Fy)return; Fp[Fx]=Fy; } void uni2(int x,int y){ int Fx=find2(x),Fy=find2(y); if(Fx==Fy)return; Fw[Fx]=Fy; } void dfs1(int x,int l){ for (int i=0;i<a[x];i++) if (!vis1[G[x][i]]&&G[x][i]>=l){ vis1[G[x][i]]=1; dfs1(G[x][i],l); } } bool dfs2(int x,int l,int r){ for (int i=0;i<a[x];i++) if (!vis2[G[x][i]]&&G[x][i]<=r){ vis2[G[x][i]]=1; if (l<=G[x][i]&&G[x][i]<=r)return 1; else return dfs2(G[x][i],l,r); } } Vec check_validity(int N,Vec X,Vec Y,Vec S,Vec E,Vec L,Vec R) { int M=X.size(),Q=S.size(); Vec A; A.clear(); if(M==N-1){ for (int q=0;q<Q;q++){ memset(a,0,sizeof(a)); memset(vis1,0,sizeof(vis1)); memset(vis2,0,sizeof(vis2)); for (int i=0;i<M;i++){ X[i].push_back(Y[i]); Y[i].push_back(X[i]); a[X[i]]++;a[Y[i]]++; } dfs1(S[q],L[q]);//people if(dfs2(E[q],L[q],R[q]))A.push_back(1);//werewolf else push_back(0); } }else{ for (int q=0;q<Q;q++){ for (int i=0;i<N;i++)Fp[i]=i,Fw[i]=i; for (int i=0;i<M;i++){ if (X[i]>=L[q]&&Y[i]>=L[q])uni1(X[i],Y[i]); if (X[i]<=R[q]&&Y[i]<=R[q])uni2(X[i],Y[i]); } int no=1; for (int i=L[q];i<=R[q];i++) if (find1(Fp[S[q]])==find1(Fp[i])&&find2(Fw[E[q]])==find2(Fw[i])){ no=0;A.push_back(1);break; } if(no)A.push_back(0); } } return A; }

Compilation message (stderr)

werewolf.cpp: In function 'Vec check_validity(int, Vec, Vec, Vec, Vec, Vec, Vec)':
werewolf.cpp:45:10: error: request for member 'push_back' in 'X.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     X[i].push_back(Y[i]);
          ^~~~~~~~~
werewolf.cpp:46:10: error: request for member 'push_back' in 'Y.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     Y[i].push_back(X[i]);
          ^~~~~~~~~
werewolf.cpp:51:9: error: 'push_back' was not declared in this scope
    else push_back(0);
         ^~~~~~~~~
werewolf.cpp: In function 'bool dfs2(int, int, int)':
werewolf.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^