This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
namespace {
const int N=100050;
int dist[N];
vector<int> E[N];
void AddEdge(int u,int v){E[u].pb(v);E[v].pb(u);}
void BFS(int n,int m){
queue<int> q;
q.push(0);dist[0]=1;
while(q.size()){
int u=q.front();
q.pop();
for(int v:E[u])if(!dist[v]){
dist[v]=dist[u]+1;
q.push(v);
}
}
}
vector<int> Solve(int n,int m,vector<int> u,vector<int> v){
vector<int> col;
for(int i=0;i<m;i++){
int a=u[i],b=v[i];
if(dist[a]>dist[b])swap(a,b);
if(dist[a]==dist[b])col.pb((dist[b]+1)%3);
else col.pb(dist[b]%3);
}
return col;
}
vector<int> Solve2(int n,int m,vector<int> u,vector<int> v){
vector<int> col;
for(int i=0;i<m;i++){
int a=u[i],b=v[i];
if(dist[a]>dist[b])swap(a,b);
if(dist[a]==dist[b])col.pb((dist[b]+1)%2);
else col.pb(dist[b]%2);
}
return col;
}
} // namespace
vector<int> Mark(int n,int m,int a,int b,vector<int> u,vector<int> v){
for(int i=0;i<m;i++)::AddEdge(u[i],v[i]);
::BFS(n,m);
if(a>2)return ::Solve(n,m,u,v);
else return ::Solve2(n,m,u,v);
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int a,b,now;
bool fir;
} // namespace
void Init(int a,int b){
::a=a;
::b=b;
::fir=1;
if(a==2)::now=1;
}
int Move(vector<int> y){
if(::a>2){
//if(::fir==1){
// ::fir=0;
int cnt=0;
for(int i=0;i<3;i++)if(y[i]!=0)cnt++;
if(cnt<2){
assert(cnt==1);
for(int i=0;i<3;i++)if(y[i]!=0)::now=i;
}else{
assert(cnt==2);
if(y[0]==0)::now=1;
else if(y[1]==0)::now=2;
else ::now=0;
}
return ::now;
/*}else{
::now=(::now+2)%3;
return ::now;
}*/
}else{
if(!y[0]&&!y[1])return -1;
::now^=1;
if(!y[::now])::now^=1;
return ::now;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |