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>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
vector<pair<int,int>> adj[20000];
int dist[20000];
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
vector<int> X(M,-1);
queue<pair<int,int>> Q;
memset(dist,-1,sizeof(dist));
for(int i=0;i<M;i++) {
adj[U[i]].emplace_back(V[i],i);
adj[V[i]].emplace_back(U[i],i);
}
dist[0]=0;
for(auto[n,t]: adj[0]) {
dist[n]=1; X[t]=0;
Q.emplace(n,t);
}
while(!Q.empty()) {
auto[c,p]=Q.front();
Q.pop();
for(auto[n,t]: adj[c]) {
if(dist[n]==-1) {
dist[n]=dist[c]+1;
if(A==2) {
if(X[p]>1) {
if(adj[c].size()==2) X[t]=(X[p]-1)%6+2;
else X[t]=!(X[p]==3 || X[p]==6 || X[p]==7);
}
else {
if(adj[c].size()==2) X[t]=X[p]+3;
else X[t]=X[p]^1;
}
}
else X[t]=min(dist[c],dist[n])%3;
Q.emplace(n,t);
}
else if(X[t]==-1) X[t]=min(dist[c],dist[n])%3;
}
}
if(A==2) for(auto &p: X) p=p==1 || p==3 || p==6 || p==7;
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
int A, r;
bool d;
string s;
void Init(int A, int B) {
::A=A;
r=-1; d=false; s="";
}
int Move(std::vector<int> y) {
if(r!=-1) y[r]++;
if(A==2) {
if(d) {
if(y[0]+y[1]==2) {
y[r]--;
for(int i=0;i<2;i++) if(y[i]) return r=i;
}
for(int i=0;i<2;i++) if(y[i]==1) return r=i;
}
else {
if(y[0]+y[1]>2) {
d=true;
if(r!=-1 && --y[r]==0) return -1;
else {
for(int i=0;i<2;i++) if(y[i]==1 && y[i]+(i==r)==1) return r=i;
}
}
if(y[0]+y[1]==1) {
d=true;
for(int i=0;i<2;i++) if(y[i]) {
if(i==r) return -1;
return r=i;
}
}
if(s.size()==4) {
int cnt=0;
d=true;
y[r]--;
for(int i=0;i<2;i++) if(y[i]) s.push_back('0'+i);
for(auto c: s) cnt+=c-'0';
s.push_back('0'+(cnt==2));
for(int i=0;i<6;i++) {
bool valid=true;
for(int j=0;j<4;j++) valid&=s[(i+j)%6]=='1'-j/2;
if(valid) for(int i=0;i<2;i++) if(y[i]) return r=i;
}
return -1;
}
if(r!=-1) y[r]--;
for(int i=0;i<2;i++) if(y[i]) {
if(r==-1) {
y[i]--;
for(int j=0;j<2;j++) if(y[j]) s.push_back('0'+j);
}
s.push_back('0'+i);
return r=i;
}
}
}
else {
for(int i=0;i<3;i++) if(y[i]==0 && y[(i+1)%3]==0) return r=(i+2)%3;
for(int i=0;i<3;i++) if(y[i]==0) return r=(i+1)%3;
}
}
Compilation message (stderr)
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
77 | }
| ^
# | 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... |