#include "Anthony.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
namespace anton {
const int maxn = 1<<17;
vector<int> val, p, pidx, col, god = {0, 0, 1, 0, 1, 1};
vector<array<int, 2>> g[maxn];
void dfs(int v) {
for(auto &[i, idx] : g[v]) if(i != p[v]) {
p[i] = v, pidx[i] = idx;
col[i] = col[v]^1;
dfs(i);
}
//cout << v << " // " << col[v] << '\n';
if(!v || g[v].size() == 2) return;
int u = p[v];
vector<int> l {v};
while(u && g[u].size() == 2) {
l.pb(u);
u = p[u];
}
int b = 0;
while(god[b] != col[v] || god[(b + l.size() - 1)%6] != col[l.back()]) b++;
//cout << v << " /// " << b << endl;
//cout << god[b] << " vs " << col[v] << '\n';
for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
}
}
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
using namespace anton;
val.resize(M);
for(int i = 0; i < M; i++) {
g[U[i]].pb({V[i], i});
g[V[i]].pb({U[i], i});
}
p.resize(N);
pidx.resize(N);
col.resize(N);
dfs(0);
//for(int i = 0; i < M; i++) cout << U[i] << " " << V[i] << " " << val[i] << '\n';
return val;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
namespace kate {
int A, B, gg = 0, lst = -2, mvs = 0;
string cur, god = "110100110100";
int decide(vector<int> c) {
if(mvs++ > 10 && !gg) exit(-1);
if(c[0] + c[1] == 0) {
gg = 1;
return -1;
}
if(lst == -2 && c[0]+c[1] == 1) {
gg = 1;
return lst = c[1];
}
if(c[0] + c[1] + (lst != -2) > 2) {
gg = 1;
if(c[0] == 0) return -1;
if(c[1] == 0) return -1;
if(c[0] == 1) return lst = 0;
if(c[1] == 1) return lst = 1;
exit(-1);
}
if(c[0] + c[1] == 2) {
if(c[0]) {
cur.pb('0'+c[1]);
cur.pb('0');
return lst = 0;
}
cur += "11";
return lst = 1;
}
if(gg) return lst = c[1];
cur.pb('0'+c[1]);
if(cur.size() == 5) {
gg = 1;
//cout << " " << gg << "Yay\n";
if(god.find(cur) != string::npos) return -1;
}
return lst = c[1];
}
} // namespace
void Init(int A, int B) {
kate::A = A;
kate::B = B;
}
int Move(std::vector<int> y) {
//cout << y[0] << " " << y[1] << " go ";
int t = kate::decide(y);
//cout <<kate::cur << " " << t << endl;
return t;
}
Compilation message
Anthony.cpp: In function 'void anton::dfs(int)':
Anthony.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
19060 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
19060 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
16888 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
16888 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
6912 KB |
Output is correct |
2 |
Correct |
10 ms |
6976 KB |
Output is correct |
3 |
Correct |
13 ms |
6912 KB |
Output is correct |
4 |
Correct |
11 ms |
6912 KB |
Output is correct |
5 |
Correct |
11 ms |
6912 KB |
Output is correct |
6 |
Correct |
12 ms |
6912 KB |
Output is correct |
7 |
Correct |
12 ms |
6912 KB |
Output is correct |
8 |
Correct |
11 ms |
6912 KB |
Output is correct |
9 |
Correct |
13 ms |
6912 KB |
Output is correct |
10 |
Correct |
11 ms |
6912 KB |
Output is correct |
11 |
Correct |
12 ms |
6912 KB |
Output is correct |
12 |
Incorrect |
12 ms |
6912 KB |
Wrong Answer [6] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
14404 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
14512 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |