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;
vector<vector<pair<int,int>>> graph;
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V){
graph.resize(N);
for(int i = 0 ; i < M ; i += 1){
graph[U[i]].push_back({V[i],i});
graph[V[i]].push_back({U[i],i});
}
vector<int> vals = {1,0,0,1,1,0};
bool seen[N];
memset(seen,false,sizeof seen);
vector<int> ans(M,-1);
queue<pair<int,int>> q;
q.push({0,-1});
seen[0] = true;
int dist = 0 , cnt = 0;
while(q.size()){
int f = q.size();
while(f--){
pair<int,int> curr = q.front();
q.pop();
int cnt = 0;
vector<pair<int,int>> vv;
for(pair<int,int> i : graph[curr.first]){
if(!seen[i.first]){
vv.push_back(i);
cnt += 1;
}
}
if(cnt > 1 && curr.first != 0){
for(pair<int,int> i : graph[curr.first]){
if(!seen[i.first]){
ans[i.second] = 1-ans[curr.second];
q.push({i.first,i.second});
seen[i.first] = true;
}
}
}else{
for(pair<int,int> i : graph[curr.first]){
if(!seen[i.first]){
ans[i.second] = dist;
q.push({i.first,i.second});
seen[i.first] = true;
}
}
}
}
dist = vals[cnt];
cnt = (cnt+1)%6;
}
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int A,B,cnt=0,last=-1;
vector<int> vals;
void Init(int a, int b) {
A = a;
B = b;
}
void shift(){
vector<int> vv;
for(int i = 1 ; i < 6 ; i += 1){
vv.push_back(vals[i]);
}
vv.push_back(vals[0]);
vals = vv;
}
bool ok(){
vector<int> vv = {1,0,0,1,1,0};
for(int i = 0 ; i < 6 ; i += 1){
shift();
if(vals == vv){
vals.clear();
return true;
}
}
vals.clear();
return false;
}
int Move(vector<int> y){
if(cnt < 6){
if(cnt == 0 && y[0]+y[1] > 2){
cnt = 6;
if(y[0] == 1){
return last = 0;
}
return last = 1;
}else if(cnt > 0 && y[0]+y[1] > 1){
cnt = 6;
if(y[1-last] == 1){
return last = 1-last;
}
return -1;
}
if(cnt == 0){
cnt += 1;
if(y[0]){
vals.push_back(0);
return last = 0;
}
vals.push_back(1);
return last = 1;
}
if(y[0] == 1){
cnt += 1;
vals.push_back(0);
return last = 0;
}else if(y[1] == 1){
cnt += 1;
vals.push_back(1);
return last = 1;
}else{
cnt = 6;
return -1;
}
}
if(y[0]+y[1] > 1){
return last = 1-last;
}
if(vals.size() == 6){
if(ok()){
return -1;
}
}
if(y[0]+y[1] == 1){
if(y[0] == 1){
return last = 0;
}
return last = 1;
}
}
Compilation message (stderr)
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |