#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 {};
}
}
#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 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
Catherine.cpp: In function 'int {anonymous}::cnt(bool)':
Catherine.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | 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:69:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
| ~~^~~~~~~~~~
Catherine.cpp:89:1: warning: control reaches end of non-void function [-Wreturn-type]
89 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2808 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2808 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2808 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2808 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1056 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
1 ms |
1052 KB |
Output is correct |
4 |
Correct |
2 ms |
1056 KB |
Output is correct |
5 |
Correct |
1 ms |
1040 KB |
Output is correct |
6 |
Correct |
1 ms |
1052 KB |
Output is correct |
7 |
Correct |
1 ms |
1056 KB |
Output is correct |
8 |
Correct |
2 ms |
1044 KB |
Output is correct |
9 |
Correct |
0 ms |
1052 KB |
Output is correct |
10 |
Correct |
0 ms |
1056 KB |
Output is correct |
11 |
Correct |
0 ms |
1056 KB |
Output is correct |
12 |
Incorrect |
1 ms |
1048 KB |
Wrong Answer [5] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
11676 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
11852 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |