#include "Anthony.h"
#define MAXN 20007
#include <bits/stdc++.h>
namespace {
int a,b;
int d[MAXN],nz[6]={0,1,0,0,1,1};
std::vector<int> g[MAXN],ind[MAXN],X;
void dfs(int s,int f,int a)
{
if(g[s].size() + (s==0) ==2) {for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[a]; dfs(g[s][i],s,(a+1)%6);}}
else for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[a]; dfs(g[s][i],s,1-nz[a]);}
}
}
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V)
{
for(int i=0;i<M;i++) X.push_back(0);
a=A;
for(int i=0;i<M;i++) g[U[i]].push_back(V[i]);
for(int i=0;i<M;i++) ind[U[i]].push_back(i);
for(int i=0;i<M;i++) g[V[i]].push_back(U[i]);
for(int i=0;i<M;i++) ind[V[i]].push_back(i);
if(a>=3)
{
d[0]=0;
std::fill(d+1,d+N,-1);
std::queue<int> q;
q.push(0);
while(!q.empty())
{
int u=q.front();
q.pop();
for(int i=0;i<g[u].size();i++) if(d[g[u][i]]==-1)
{
d[g[u][i]]=d[u]+1;
q.push(g[u][i]);
}
for(int i=0;i<M;i++) X[i]=std::min(d[U[i]],d[V[i]])%3;
}
}
else dfs(0,0,0);
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
namespace {
int a, b,br,nz[6]={0,1,0,0,1,1},pr;
bool sig=false;
std::vector<int> vd;
}
void Init(int A, int B) {
a = A;
b = B;
}
int Move(std::vector<int> y) {
if(a>=3) {for(int i=0;i<3;i++) if(y[i]==0 && y[(i+1)%3]!=0) return (i+1)%3;}
else
{
br++;
int deg=y[0]+y[1]+(br!=1);
if(sig)
{
if(deg>=3)
{
pr=1-pr;
return pr;
}
if(y[0]!=0) pr=0;
else pr=1;
return pr;
}
if(deg==1)
{
sig=true;
if(br!=1) return -1;
if(y[0]!=0) pr=0;
esle pr=1;
return pr;
}
if(deg>2)
{
y[pr]++;
sig=true;
if(y[0]==1) {pr=0; return 0;}
if(y[1]==1) {pr=1; return 1;}
}
if(br<=3)
{
if(y[0]!=0) pr=0;
else pr=1;
if(br==1) vd.push_back(y[1]-pr);
vd.push_back(pr);
return pr;
}
if(br==4)
{
int op;
if(y[0]!=0) op=0;
else op=1;
vd.push_back(op);
bool ok=false;
for(int i=0;i<6;i++)
{
bool tok=true;
for(int j=0;j<5;j++) if(vd[j]!=nz[(i-j+6)%6]) tok=false;
if(tok) ok=true;
}
sig=true;
if(ok) {pr=op; return pr;}
else return -1;
}
}
}
Compilation message
Anthony.cpp: In function 'void {anonymous}::dfs(int, int, int)':
Anthony.cpp:11:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(g[s].size() + (s==0) ==2) {for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[a]; dfs(g[s][i],s,(a+1)%6);}}
~^~~~~~~~~~~~
Anthony.cpp:12:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else for(int i=0;i<g[s].size();i++) if(g[s][i]!=f) {X[ind[s][i]]=nz[a]; dfs(g[s][i],s,1-nz[a]);}
~^~~~~~~~~~~~
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:34:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[u].size();i++) if(d[g[u][i]]==-1)
~^~~~~~~~~~~~
Anthony.cpp: At global scope:
Anthony.cpp:6:8: warning: '{anonymous}::b' defined but not used [-Wunused-variable]
int a,b;
^
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:38:4: error: 'esle' was not declared in this scope
esle pr=1;
^~~~
Catherine.cpp:38:4: note: suggested alternative: 'wcslen'
esle pr=1;
^~~~
wcslen
Catherine.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^