#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) 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
16212 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
24 ms |
15528 KB |
Output is correct |
4 |
Correct |
34 ms |
17228 KB |
Output is correct |
5 |
Correct |
34 ms |
17320 KB |
Output is correct |
6 |
Correct |
27 ms |
15960 KB |
Output is correct |
7 |
Correct |
28 ms |
15864 KB |
Output is correct |
8 |
Correct |
32 ms |
16704 KB |
Output is correct |
9 |
Correct |
38 ms |
16696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
16212 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
24 ms |
15528 KB |
Output is correct |
4 |
Correct |
34 ms |
17228 KB |
Output is correct |
5 |
Correct |
34 ms |
17320 KB |
Output is correct |
6 |
Correct |
27 ms |
15960 KB |
Output is correct |
7 |
Correct |
28 ms |
15864 KB |
Output is correct |
8 |
Correct |
32 ms |
16704 KB |
Output is correct |
9 |
Correct |
38 ms |
16696 KB |
Output is correct |
10 |
Correct |
26 ms |
14116 KB |
Output is correct |
11 |
Correct |
26 ms |
14144 KB |
Output is correct |
12 |
Correct |
31 ms |
14092 KB |
Output is correct |
13 |
Correct |
26 ms |
14144 KB |
Output is correct |
14 |
Correct |
26 ms |
14400 KB |
Output is correct |
15 |
Correct |
34 ms |
14632 KB |
Output is correct |
16 |
Correct |
31 ms |
16716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
13560 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
23 ms |
13116 KB |
Output is correct |
4 |
Correct |
32 ms |
15144 KB |
Output is correct |
5 |
Correct |
37 ms |
15000 KB |
Output is correct |
6 |
Correct |
26 ms |
13716 KB |
Output is correct |
7 |
Correct |
26 ms |
13652 KB |
Output is correct |
8 |
Correct |
30 ms |
14388 KB |
Output is correct |
9 |
Correct |
30 ms |
14424 KB |
Output is correct |
10 |
Correct |
28 ms |
14228 KB |
Output is correct |
11 |
Correct |
28 ms |
14152 KB |
Output is correct |
12 |
Correct |
30 ms |
14100 KB |
Output is correct |
13 |
Correct |
28 ms |
14156 KB |
Output is correct |
14 |
Correct |
30 ms |
14416 KB |
Output is correct |
15 |
Correct |
30 ms |
14388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
13560 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
23 ms |
13116 KB |
Output is correct |
4 |
Correct |
32 ms |
15144 KB |
Output is correct |
5 |
Correct |
37 ms |
15000 KB |
Output is correct |
6 |
Correct |
26 ms |
13716 KB |
Output is correct |
7 |
Correct |
26 ms |
13652 KB |
Output is correct |
8 |
Correct |
30 ms |
14388 KB |
Output is correct |
9 |
Correct |
30 ms |
14424 KB |
Output is correct |
10 |
Correct |
28 ms |
14228 KB |
Output is correct |
11 |
Correct |
28 ms |
14152 KB |
Output is correct |
12 |
Correct |
30 ms |
14100 KB |
Output is correct |
13 |
Correct |
28 ms |
14156 KB |
Output is correct |
14 |
Correct |
30 ms |
14416 KB |
Output is correct |
15 |
Correct |
30 ms |
14388 KB |
Output is correct |
16 |
Correct |
24 ms |
12116 KB |
Output is correct |
17 |
Correct |
25 ms |
12120 KB |
Output is correct |
18 |
Correct |
25 ms |
12124 KB |
Output is correct |
19 |
Correct |
25 ms |
12104 KB |
Output is correct |
20 |
Correct |
28 ms |
12900 KB |
Output is correct |
21 |
Correct |
26 ms |
12644 KB |
Output is correct |
22 |
Correct |
30 ms |
14432 KB |
Output is correct |
23 |
Correct |
26 ms |
12256 KB |
Output is correct |
24 |
Correct |
25 ms |
12388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1572 KB |
Output is correct |
2 |
Correct |
1 ms |
1328 KB |
Output is correct |
3 |
Correct |
1 ms |
1580 KB |
Output is correct |
4 |
Correct |
2 ms |
1580 KB |
Output is correct |
5 |
Correct |
2 ms |
1556 KB |
Output is correct |
6 |
Correct |
2 ms |
2072 KB |
Output is correct |
7 |
Correct |
2 ms |
1572 KB |
Output is correct |
8 |
Correct |
2 ms |
1564 KB |
Output is correct |
9 |
Correct |
2 ms |
1580 KB |
Output is correct |
10 |
Correct |
2 ms |
1596 KB |
Output is correct |
11 |
Correct |
2 ms |
1960 KB |
Output is correct |
12 |
Incorrect |
1 ms |
1564 KB |
Wrong Answer [5] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
11600 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
11596 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |