This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// .. And I love you, it's ruining my life
#include "Anthony.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
namespace
{
const int d[6] = { 0, 0, 1, 0, 1, 1 };
vector<vector<pair<int, int> > > g;
vector<int> col;
void dfs2(int u, int p = -1, int c = 1, int i = -1)
{
if (!u || g[u].size() != 2)
{
for (pair<int, int> v : g[u]) if (v.first != p)
{
col[v.second] = c ^ 1;
dfs2(v.first, u, (c ^ 1));
}
}
else
{
if (i == -1) i = (c ? 2 : 0);
for (pair<int, int> v : g[u]) if (v.first != p)
{
col[v.second] = d[(i + 1) % 6];
dfs2(v.first, u, d[(i + 1) % 6], (i + 1) % 6);
}
}
}
void bfs3()
{
vector<int> d(g.size(), -1);
d[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty())
{
int u = q.front();
q.pop();
for (pair<int, int> v : g[u])
{
if (d[v.first] == -1)
{
q.push(v.first);
d[v.first] = d[u] + 1;
}
col[v.second] = min(d[v.first], d[u]) % 3;
}
}
}
}
vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v)
{
col.assign(m, -1), g.assign(n, {});
for (int i = 0; i < m; i++) g[u[i]].push_back({ v[i], i }), g[v[i]].push_back({ u[i], i });
if (a == 2)
{
::dfs2(0);
return col;
}
else
{
::bfs3();
return col;
}
}
// All my mornings are Mondays stuck in an endless February...
// I took the miracle move-on drug, the effects were temporary
#include "Catherine.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
namespace
{
const int d[6] = { 0, 0, 1, 0, 1, 1 };
int a, b, lst, go;
vector<int> v;
int cnt(bool rev = false)
{
int ans = 0;
vector<int> v2 = v;
if (rev) reverse(v2.begin(), v2.end());
for (int i = 0; i < 6; i++)
{
bool ok = true;
for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
{
ok = false;
break;
}
if (ok) ans++;
}
return ans;
}
}
void Init(int A, int B)
{
::a = A;
::b = B;
lst = -1, go = 0;
v.clear();
}
int Move(vector<int> y)
{
if (a == 2)
{
int sum = y[0] + y[1] + (lst != -1);
if (sum != 2)
{
go = 1;
if (lst != -1) y[lst]++;
int x = (y[0] == 1 ? 0 : 1);
if (lst == x) return lst = x, -1;
return lst = x;
}
if (go == 1)
{
return lst = (y[0] == 1 ? 0 : 1);
}
for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
int fw = cnt(false), bk = cnt(true);
if (bk == 0) // ideme sa otocit
{
go = 1;
return -1;
}
if (fw == 0) // navzdy budem pokracovat v tomto smere
{
go = 1;
int x = (y[0] == 1 ? 0 : 1);
return lst = x;
}
if (lst == -1) // prvy vrchol
{
if (v.back() != 1) reverse(v.begin(), v.end());
return lst = v[1];
}
return lst = (y[0] == 1 ? 0 : 1);
}
else
{
if (lst != -1) y[lst]++;
if (!y[0] && !y[1]) return lst = 2;
if (!y[0] && !y[2]) return lst = 1;
if (!y[1] && !y[2]) return lst = 0;
if (!y[0]) return lst = 1;
if (!y[1]) return lst = 2;
if (!y[2]) return lst = 0;
}
}
Compilation message (stderr)
Catherine.cpp: In function 'int {anonymous}::cnt(bool)':
Catherine.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
| ~~^~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
| ~~^~~~~~~~~~
Catherine.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
102 | }
| ^
# | 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... |