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 fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
namespace {
vector<int> g[200010];
int d[200010] = {};
int num[200010] = {};
int ret[200010] = {1, };
int tb[6] = {1, 1, 0, 1, 0, 0};
int p[200010] = {};
int f(int i) {
if(ret[i] < 2) return ret[i];
return tb[ret[i] % 6];
}
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
for(int i=0; i<M; i++) g[U[i]].eb(V[i]), g[V[i]].eb(U[i]);
queue<int> q;
q.em(0);
d[0] = 1;
vector<int> v;
while(q.size()) {
int x = q.front();
q.pop();
v.eb(x);
for(auto i : g[x]) {
if(d[i]) continue;
if(g[i].size() == 2 && g[x].size() == 2 && x != 0) ret[i] = 2;
else if(x == 0 || g[x].size() != 2) ret[i] = 1 - ret[x];
else ret[i] = 1;
p[i] = x;
d[i] = d[x] + 1;
q.em(i);
}
}
reverse(all(v));
for(auto i : v) {
if(ret[i] != 2) continue;
if(g[i][0] != p[i]) ret[i] = ret[g[i][0]] + 1;
else ret[i] = ret[g[i][1]] + 1;
}
std::vector<int> X(M);
for (int i = 0; i < M; ++i) {
if(p[U[i]] == V[i]) X[i] = f(U[i]);
else X[i] = f(V[i]);
// cout << X[i];
}
//cout << endl;
return X;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
namespace {
int cnt = 0;
int a, b;
int x = 0;
} // namespace
void Init(int A, int B) {
a = A;
b = B;
}
int Move(std::vector<int> y) {
//cout << "!" << x << endl;
if(y[0] + y[1] == 0) {
cnt = 4;
return -1;
}
if(y[0] > y[1] && y[1] >= 1) {
cnt = 4;
return 1;
}
if(y[1] > y[0] && y[0] >= 1) {
cnt = 4;
return 0;
}
if(y[0] > 2) {
cnt = 4;
return -1;
}
if(y[1] > 2) {
cnt = 4;
return -1;
}
if(y[0] + y[1] == 2) {
cnt = 0;
if(y[0] == 0) {
x = 3;
return 1;
}
if(y[0] == 1) {
if(x & 1) {
x = 2;
return 0;
}
else {
x = 1;
return 1;
}
}
else {
if(x & 1) {
cnt = 4;
return -1;
}
return 0;
}
}
if(y[0] + y[1] == 1) {
cnt++;
x <<= 1;
x |= y[1];
x &= 31;
//cout << cnt << " " << x << endl;
if(cnt == 3) {
if(x == 5 || x == 11 || x == 22 || x == 12 || x == 25 || x == 18) {
cnt = 4;
return -1;
}
else {
cnt = 4;
return y[1];
}
}
return y[1];
}
}
Compilation message (stderr)
Anthony.cpp:23:5: warning: '{anonymous}::num' defined but not used [-Wunused-variable]
int num[200010] = {};
^~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:103: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... |