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>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
vector <ll> s={0, 1, 0, 0, 1, 1};
vector <ll> Mark(ll n, ll m, ll a, ll b, vector <ll> U, vector <ll> V)
{
vector <ll> ans(m);
vector <vector <pll>> A(n);
for (ll i=0; i<m; i++)
A[U[i]].pb({V[i], i}), A[V[i]].pb({U[i], i});
vector <ll> dep(n, 0);
auto bfs=[&]()
{
queue <ll> q; q.push(0), dep[0]=1;
while (!q.empty())
{
ll u=q.front(); q.pop();
for (auto [v, id]:A[u])
{
if (!dep[v])
q.push(v), dep[v]=dep[u]+1;
ans[id]=min(dep[u], dep[v])%3;
}
}
};
function <void(int, int)> dfs=[&](ll u, ll pa)
{
ll cnt=A[u].size()-(pa!=-1);
for (auto [v, id]:A[u])
{
if (v==pa) continue;
if (cnt==1 || pa==-1)
ans[id]=s[dep[u]], dep[v]=(dep[u]+1)%6;
else ans[id]=s[(dep[u]+5)%6]^1, dep[v]=ans[id]^1;
dfs(v, u);
}
};
if (a>2) bfs();
else dfs(0, -1);
return ans;
}
#include "Catherine.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
string crr;
ll A, B, cnt, ok, last=-1;
void Init(ll a, ll b) {A=a, B=b;}
ll Move(vector <ll> y)
{
if (A>2)
{
if (!y[0] && !y[1]) return 2;
if (!y[2] && !y[1]) return 0;
if (!y[0] && !y[2]) return 1;
if (y[0] && y[1]) return 0;
if (y[1] && y[2]) return 1;
return 2;
}
if (ok)
{
if (!y[0]) return last=1;
if (!y[1]) return last=0;
return last=last^1;
}
cnt++; if (cnt==4) ok=1;
if (last==-1)
{
ll s=y[0]+y[1];
if (s>=3 && y[0]>1) {ok=1; return last=1;}
if (s>=3 && y[1]>1) {ok=1; return last=0;}
if (s<=1 && !y[0]) {ok=1; return last=1;}
if (s<=1 && !y[1]) {ok=1; return last=0;}
if (y[0]>1) {crr="00"; return last=0;}
if (y[1]>1) {crr="11"; return last=1;}
crr="01"; return last=1;
}
if (!y[0] && !y[1]) {ok=1; return -1;}
if (!y[last] && y[last^1]>1) {ok=1; return -1;}
if (y[0] && y[1]) {ok=1; return last=last^1;}
if (cnt<4)
{
if (y[0]) {crr.pb('0'); return last=0;}
if (y[1]) {crr.pb('1'); return last=1;}
}
crr.pb(y[0]?'0':'1');
if (crr=="01001") return -1;
if (crr=="10011") return -1;
if (crr=="00110") return -1;
if (crr=="01101") return -1;
if (crr=="11010") return -1;
if (crr=="10100") return -1;
if (y[0]) return last=0;
return last=1;
}
# | 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... |