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);
}
}
}
}
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
{
return {};
}
}
// 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);
}
}
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:92:1: warning: control reaches end of non-void function [-Wreturn-type]
92 | }
| ^
# | 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... |