#include "Anthony.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> graf[20005];
int dist[20005],sta[20005],pret=-1;
queue<int> Q;
string E;
int N;
bool prosli[20005];
void BFS(int gde){
for(int i=0;i<=N;i++)
dist[i]=-1;
dist[gde]=0;
Q.push(gde);
while(Q.size()){
int tren=Q.front();
Q.pop();
if(prosli[tren])
continue;
//cout<<tren<<endl;
prosli[tren]=true;
for(int i=0;i<graf[tren].size();i++)
if(dist[graf[tren][i]]==-1){
dist[graf[tren][i]]=dist[tren]+1;
Q.push(graf[tren][i]);
}
}
return;
}
void dfs2(int gde,int pret,int cyc){
if(gde==pret){
for(int i=0;i<graf[gde].size();i++){
dfs2(graf[gde][i],gde,0);
}
return;
}
// cout<<gde<<" "<<cyc<<endl;
if(cyc==16)
sta[gde]=0;
if(cyc==32)
sta[gde]=1;
if(cyc<=5)
sta[gde]=E[cyc]-'0';
if(graf[gde].size()>2){
if(sta[gde]==1)
cyc=16;
else
cyc=32;
for(int i=0;i<graf[gde].size();i++){
if(graf[gde][i]!=pret)
dfs2(graf[gde][i],gde,cyc);
}
return;
}
if(cyc>=16)
for(int i=0;i<E.size();i++)
if(E[i]==sta[gde]+'0'){
cyc=i;
}
cyc++;
if(cyc==6)
cyc=0;
for(int i=0;i<graf[gde].size();i++)
if(graf[gde][i]!=pret)
dfs2(graf[gde][i],gde,cyc);
return;
}
vector<int> Mark(int n, int M, int A, int B, vector<int> U,vector<int> V) {
N=n;
for(int i=0;i<M;i++){
graf[U[i]].push_back(V[i]);
graf[V[i]].push_back(U[i]);
}
BFS(0);
/*for(int i=0;i<N;i++)
cout<<dist[i]<<" ";
cout<<endl;*/
if(A==2){
E="001011";
vector<int> R;
dfs2(0,0,-1);
for(int i=0;i<M;i++){
int koj;
if(dist[U[i]]>dist[V[i]])
koj=U[i];
else
koj=V[i];
R.push_back(sta[koj]);
}
return R;
}
string S="012";
vector<int> R;
for(int i=0;i<M;i++){
int md=min(dist[U[i]],dist[V[i]]);
R.push_back(S[md%3]-'0');
}
return R;
}
#include "Catherine.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int slucaj,nalazi=0;
set<string> S;
void Init(int A, int B) {
if(A==2){
slucaj=2;
string x="001011";
x+=x;
x+=x;
for(int i=0;i+4<x.size();i++)
S.insert(x.substr(i,5));
}
else
slucaj=1;
}
bool prvipot=true;
string T;
int Move(std::vector<int> y) {
if(slucaj==1){
if(y[0]==0 and y[1]==0)
return 2;
if(y[0]==0 and y[2]==0)
return 1;
if(y[1]==0 and y[2]==0)
return 0;
if(y[0]==0)
return 1;
if(y[1]==0)
return 2;
return 0;
}
// cout<<"POTEZ "<<y[0]<<" "<<y[1]<<endl;
if(0==y[0] and y[1]==0){
nalazi=4;
prvipot=false;
return -1;
}
if(prvipot){
if(y[0]==1 and y[1]>1){
nalazi=4;
pret=0;
return 0;
}
if(y[1]==1 and y[0]>1){
nalazi=4;
pret=1;
return 1;
}
}
else{
if(pret==1 and y[1]==0 and y[0]>1){
nalazi=4;
return -1;
}
if(pret==0 and y[0]==0 and y[1]>1){
nalazi=4;
return -1;
}
if(pret==0 and y[1]==1 and y[0]>=1){
pret=1;
return 1;
}
if(pret==1 and y[0]==1 and y[1]>=1){
pret=0;
return 0;
}
}
if(nalazi==0){
prvipot=false;
if(y[0]==0 and y[1]==1){
nalazi=4;
pret=1;
return 1;
}
if(y[1]==0 and y[0]==1){
nalazi=4;
pret=0;
return 0;
}
nalazi++;
if(y[0]==2){
T+="00";
pret=0;
return 0;
}
if(y[1]==2){
T+="11";
pret=1;
return 1;
}
T+="01";
pret=1;
return 1;
}
if(nalazi==1 or nalazi==2){
if(y[0]==1){
T+="0";
nalazi++;
pret=0;
return 0;
}
T+="1";
nalazi++;
pret=1;
return 1;
}
if(nalazi==3){
if(y[0]==1)
T+="0";
else
T+="1";
//cout<<T<<endl;
nalazi++;
if(S.find(T)!=S.end()){
// cout<<"LOSE"<<endl;
return -1;
}
if(y[0]==1){
pret=0;
return 0;
}
pret=1;
return 1;
}
if(y[0]==0){
nalazi=4;
pret=1;
return 1;
}
if(y[1]==0){
pret=0;
return 0;
}
return -1;
}
Compilation message
Anthony.cpp: In function 'void BFS(int)':
Anthony.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i=0;i<graf[tren].size();i++)
| ~^~~~~~~~~~~~~~~~~~
Anthony.cpp: In function 'void dfs2(int, int, int)':
Anthony.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i=0;i<graf[gde].size();i++){
| ~^~~~~~~~~~~~~~~~~
Anthony.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i=0;i<graf[gde].size();i++){
| ~^~~~~~~~~~~~~~~~~
Anthony.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int i=0;i<E.size();i++)
| ~^~~~~~~~~
Anthony.cpp:64:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int i=0;i<graf[gde].size();i++)
| ~^~~~~~~~~~~~~~~~~
Catherine.cpp: In function 'void Init(int, int)':
Catherine.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=0;i+4<x.size();i++)
| ~~~^~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:44:10: error: 'pret' was not declared in this scope
44 | pret=0;
| ^~~~
Catherine.cpp:49:10: error: 'pret' was not declared in this scope
49 | pret=1;
| ^~~~
Catherine.cpp:54:10: error: 'pret' was not declared in this scope
54 | if(pret==1 and y[1]==0 and y[0]>1){
| ^~~~
Catherine.cpp:58:10: error: 'pret' was not declared in this scope
58 | if(pret==0 and y[0]==0 and y[1]>1){
| ^~~~
Catherine.cpp:62:10: error: 'pret' was not declared in this scope
62 | if(pret==0 and y[1]==1 and y[0]>=1){
| ^~~~
Catherine.cpp:66:10: error: 'pret' was not declared in this scope
66 | if(pret==1 and y[0]==1 and y[1]>=1){
| ^~~~
Catherine.cpp:75:10: error: 'pret' was not declared in this scope
75 | pret=1;
| ^~~~
Catherine.cpp:80:10: error: 'pret' was not declared in this scope
80 | pret=0;
| ^~~~
Catherine.cpp:86:10: error: 'pret' was not declared in this scope
86 | pret=0;
| ^~~~
Catherine.cpp:91:10: error: 'pret' was not declared in this scope
91 | pret=1;
| ^~~~
Catherine.cpp:95:7: error: 'pret' was not declared in this scope
95 | pret=1;
| ^~~~
Catherine.cpp:102:10: error: 'pret' was not declared in this scope
102 | pret=0;
| ^~~~
Catherine.cpp:107:7: error: 'pret' was not declared in this scope
107 | pret=1;
| ^~~~
Catherine.cpp:122:10: error: 'pret' was not declared in this scope
122 | pret=0;
| ^~~~
Catherine.cpp:125:7: error: 'pret' was not declared in this scope
125 | pret=1;
| ^~~~
Catherine.cpp:130:7: error: 'pret' was not declared in this scope
130 | pret=1;
| ^~~~
Catherine.cpp:134:7: error: 'pret' was not declared in this scope
134 | pret=0;
| ^~~~