#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define isz(a) (int)(a).size()
#define pii pair <int, int>
#define fi first
#define se second
#define mp make_pair
const int NM = 2e4, f[] = {0, 1, 0, 0, 1, 1};
vector <pii> adj[NM+5];
vector <int> ans;
queue <int> q;
int dep[NM+5];
void bfs(){
for (int i = 0; i < NM; i++) dep[i] = -1;
dep[0] = 0;
while (!q.empty()) q.pop();
q.push(0);
while (!q.empty()){
int u = q.front(); q.pop();
for (pii _ : adj[u]){
int v = _.fi, id = _.se;
if (dep[v] != -1){
ans[id] = dep[v]%3;
}
else{
ans[id] = dep[u]%3;
dep[v] = dep[u]+1;
q.push(v);
}
}
}
}
void dfs(int u, int p, int m){
int child = isz(adj[u])-(p != -1);
if (child == 1 || p == -1){
for (pii _ : adj[u]){
int v = _.fi, id = _.se;
if (v == p) continue;
ans[id] = f[m];
dfs(v, u, (m+1)%6);
}
}
else{
for (pii _ : adj[u]){
int v = _.fi, id = _.se;
if (v == p) continue;
if (f[(m+5)%6] == 0){
ans[id] = 1;
dfs(v, u, 1);
}
else{
ans[id] = 0;
dfs(v, u, 0);
}
}
}
}
vector <int> Mark(int N, int M, int A, int B, vector <int> U, vector <int> V){
ans.resize(M);
for (int i = 0; i < M; i++){
adj[U[i]].push_back(mp(V[i], i));
adj[V[i]].push_back(mp(U[i], i));
}
if (A > 2){
bfs();
}
else{
dfs(0, -1, 0);
}
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int A, B;
int nMove = 0;
bool oriented = 0;
int lst = -1;
string s = "";
int tmp = -1;
void Init(int _A, int _B){
A = _A, B = _B;
}
int Move(vector<int> y){
if (A > 2){
if (y[1] == 0 && y[2] == 0) return 0;
if (y[0] == 0 && y[2] == 0) return 1;
if (y[0] == 0 && y[1] == 0) return 2;
if (y[2] == 0) return 0;
if (y[0] == 0) return 1;
return 2;
}
++nMove;
if (oriented){
if (y[0] == 0 && y[1] == 0) return -1;
if (y[0] == 0) return lst = 1, 1;
if (y[1] == 0) return lst = 0, 0;
if (lst == 0) return lst = 1, 1;
return lst = 0, 0;
}
if (nMove == 1){
if (y[0] == 0 && y[1] == 1){
oriented = 1;
return lst = 1, 1;
}
if (y[1] == 0 && y[0] == 1){
oriented = 1;
return lst = 0, 0;
}
if (y[1] == 1 && y[0] > 1){
oriented = 1;
return lst = 1, 1;
}
if (y[0] == 1 && y[1] > 1){
oriented = 1;
return lst = 0, 0;
}
if (y[0] == 0 && y[1] == 2){
s.push_back('1');
tmp = 1;
return lst = 1, 1;
}
if (y[0] == 2 && y[1] == 0){
s.push_back('0');
tmp = 0;
return lst = 0, 0;
}
s.push_back('0');
tmp = 1;
return lst = 0, 0;
}
if (y[0] == 0 && y[1] == 0){
oriented = 1;
return -1;
}
if (y[0] == 0 && y[1] > 1){
oriented = 1;
return -1;
}
if (y[1] == 0 && y[0] > 1){
oriented = 1;
return -1;
}
if (y[0] > 0 && y[1] > 0){
oriented = 1;
if (lst == 0) return lst = 1, 1;
return lst = 0, 0;
}
if (nMove < 4){
if (y[0] > 0){
s.push_back('0');
return lst = 0, 0;
}
s.push_back('1');
return lst = 1, 1;
}
oriented = 1;
if (s == "001" && y[1] > 0) return -1;
if (s == "010" && y[0] > 0) return -1;
if (s == "101" && y[0] > 0) return -1;
if (s == "110" && y[1] > 0) return -1;
if (s == "100" && y[1] > 0 && tmp == 0) return -1;
if (s == "011" && y[0] > 0 && tmp == 0) return -1;
if (y[0] > 0) return lst = 0, 0;
return lst = 1, 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
15704 KB |
Output is correct |
2 |
Correct |
1 ms |
1296 KB |
Output is correct |
3 |
Correct |
24 ms |
15244 KB |
Output is correct |
4 |
Correct |
36 ms |
16900 KB |
Output is correct |
5 |
Correct |
34 ms |
16692 KB |
Output is correct |
6 |
Correct |
26 ms |
15480 KB |
Output is correct |
7 |
Correct |
27 ms |
15484 KB |
Output is correct |
8 |
Correct |
32 ms |
16240 KB |
Output is correct |
9 |
Correct |
32 ms |
16240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
15704 KB |
Output is correct |
2 |
Correct |
1 ms |
1296 KB |
Output is correct |
3 |
Correct |
24 ms |
15244 KB |
Output is correct |
4 |
Correct |
36 ms |
16900 KB |
Output is correct |
5 |
Correct |
34 ms |
16692 KB |
Output is correct |
6 |
Correct |
26 ms |
15480 KB |
Output is correct |
7 |
Correct |
27 ms |
15484 KB |
Output is correct |
8 |
Correct |
32 ms |
16240 KB |
Output is correct |
9 |
Correct |
32 ms |
16240 KB |
Output is correct |
10 |
Correct |
27 ms |
13696 KB |
Output is correct |
11 |
Correct |
25 ms |
13812 KB |
Output is correct |
12 |
Correct |
26 ms |
13676 KB |
Output is correct |
13 |
Correct |
28 ms |
13652 KB |
Output is correct |
14 |
Correct |
26 ms |
13940 KB |
Output is correct |
15 |
Correct |
28 ms |
14196 KB |
Output is correct |
16 |
Correct |
31 ms |
16380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
13176 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
22 ms |
13064 KB |
Output is correct |
4 |
Correct |
38 ms |
14564 KB |
Output is correct |
5 |
Correct |
34 ms |
14716 KB |
Output is correct |
6 |
Correct |
26 ms |
13168 KB |
Output is correct |
7 |
Correct |
26 ms |
13176 KB |
Output is correct |
8 |
Correct |
30 ms |
14032 KB |
Output is correct |
9 |
Correct |
30 ms |
13868 KB |
Output is correct |
10 |
Correct |
30 ms |
13916 KB |
Output is correct |
11 |
Correct |
31 ms |
13896 KB |
Output is correct |
12 |
Correct |
27 ms |
13676 KB |
Output is correct |
13 |
Correct |
27 ms |
13728 KB |
Output is correct |
14 |
Correct |
30 ms |
13936 KB |
Output is correct |
15 |
Correct |
31 ms |
13956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
13176 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
22 ms |
13064 KB |
Output is correct |
4 |
Correct |
38 ms |
14564 KB |
Output is correct |
5 |
Correct |
34 ms |
14716 KB |
Output is correct |
6 |
Correct |
26 ms |
13168 KB |
Output is correct |
7 |
Correct |
26 ms |
13176 KB |
Output is correct |
8 |
Correct |
30 ms |
14032 KB |
Output is correct |
9 |
Correct |
30 ms |
13868 KB |
Output is correct |
10 |
Correct |
30 ms |
13916 KB |
Output is correct |
11 |
Correct |
31 ms |
13896 KB |
Output is correct |
12 |
Correct |
27 ms |
13676 KB |
Output is correct |
13 |
Correct |
27 ms |
13728 KB |
Output is correct |
14 |
Correct |
30 ms |
13936 KB |
Output is correct |
15 |
Correct |
31 ms |
13956 KB |
Output is correct |
16 |
Correct |
23 ms |
11896 KB |
Output is correct |
17 |
Correct |
23 ms |
11636 KB |
Output is correct |
18 |
Correct |
25 ms |
11644 KB |
Output is correct |
19 |
Correct |
24 ms |
11636 KB |
Output is correct |
20 |
Correct |
27 ms |
12420 KB |
Output is correct |
21 |
Correct |
26 ms |
12136 KB |
Output is correct |
22 |
Correct |
30 ms |
14212 KB |
Output is correct |
23 |
Correct |
25 ms |
11904 KB |
Output is correct |
24 |
Correct |
25 ms |
11884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1568 KB |
Output is correct |
2 |
Correct |
0 ms |
1308 KB |
Output is correct |
3 |
Correct |
2 ms |
1568 KB |
Output is correct |
4 |
Correct |
2 ms |
1568 KB |
Output is correct |
5 |
Correct |
2 ms |
1564 KB |
Output is correct |
6 |
Correct |
2 ms |
1556 KB |
Output is correct |
7 |
Correct |
1 ms |
1564 KB |
Output is correct |
8 |
Correct |
2 ms |
1568 KB |
Output is correct |
9 |
Correct |
2 ms |
1560 KB |
Output is correct |
10 |
Correct |
2 ms |
1568 KB |
Output is correct |
11 |
Correct |
2 ms |
1560 KB |
Output is correct |
12 |
Correct |
2 ms |
1568 KB |
Output is correct |
13 |
Correct |
2 ms |
1572 KB |
Output is correct |
14 |
Incorrect |
2 ms |
1576 KB |
Wrong Answer [6] |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
11128 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
11132 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |