//include "Anthony.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>
const int maxn = 20000, k = 6;
int d[maxn];
vi graph[maxn];
queue<int> q;
int s[k] = {0, 0, 1, 0, 1, 1};
vi ans;
vi Mark(int n, int m, int a, int b, vi u, vi v){
ans.resize(m);
for(int i = 0; i < m; i++){
graph[u[i]].push_back(i);
graph[v[i]].push_back(i);
}
if(a > 2){
q.push(0);
while(!q.empty()){
int c = q.front();
q.pop();
for(int i : graph[c]){
int j = u[i] ^ v[i] ^ c;
if(j && !d[j]){
d[j] = d[c] + 1;
q.push(j);
}
if(d[j] == d[c] || d[j] == d[c] + 1){
ans[i] = d[c] % 3;
}
}
}
}else{
function<void(int, int)> dfs = [&](int c, int p){
for(int i : graph[c]){
int j = u[i] ^ v[i] ^ c;
if(j != p){
ans[i] = s[d[c] % k];
d[j] = graph[j].size() > 2 ? (ans[i] ^ 1) << 1 : d[c] + 1;
dfs(j, c);
}
}
};
dfs(0, -1);
}
return ans;
}
//#include "Catherine.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>
int a, b;
int prv = -1;
void Init(int A, int B){
a = A, b = B;
}
int Move(vi v){
if(a > 2){
if(~prv) v[prv]++;
for(int i = 0; i < 3; i++){
if(v[i] && v[(i + 1) % 3]) return prv = i;
}
for(int i = 0; i < 3; i++){
if(v[i]) return prv = i;
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
16140 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
45 ms |
15412 KB |
Output is correct |
4 |
Correct |
63 ms |
17312 KB |
Output is correct |
5 |
Correct |
65 ms |
17236 KB |
Output is correct |
6 |
Correct |
52 ms |
15876 KB |
Output is correct |
7 |
Correct |
53 ms |
15864 KB |
Output is correct |
8 |
Correct |
68 ms |
16660 KB |
Output is correct |
9 |
Correct |
60 ms |
16656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
16140 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
45 ms |
15412 KB |
Output is correct |
4 |
Correct |
63 ms |
17312 KB |
Output is correct |
5 |
Correct |
65 ms |
17236 KB |
Output is correct |
6 |
Correct |
52 ms |
15876 KB |
Output is correct |
7 |
Correct |
53 ms |
15864 KB |
Output is correct |
8 |
Correct |
68 ms |
16660 KB |
Output is correct |
9 |
Correct |
60 ms |
16656 KB |
Output is correct |
10 |
Correct |
51 ms |
13920 KB |
Output is correct |
11 |
Correct |
52 ms |
13912 KB |
Output is correct |
12 |
Correct |
50 ms |
13932 KB |
Output is correct |
13 |
Correct |
54 ms |
13900 KB |
Output is correct |
14 |
Correct |
50 ms |
14228 KB |
Output is correct |
15 |
Correct |
63 ms |
14532 KB |
Output is correct |
16 |
Correct |
62 ms |
16800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
13652 KB |
Output is correct |
2 |
Correct |
9 ms |
1792 KB |
Output is correct |
3 |
Correct |
45 ms |
13344 KB |
Output is correct |
4 |
Correct |
71 ms |
15052 KB |
Output is correct |
5 |
Correct |
62 ms |
15272 KB |
Output is correct |
6 |
Correct |
50 ms |
13668 KB |
Output is correct |
7 |
Correct |
51 ms |
13660 KB |
Output is correct |
8 |
Correct |
62 ms |
14340 KB |
Output is correct |
9 |
Correct |
62 ms |
14492 KB |
Output is correct |
10 |
Correct |
60 ms |
14016 KB |
Output is correct |
11 |
Correct |
55 ms |
14204 KB |
Output is correct |
12 |
Correct |
61 ms |
14032 KB |
Output is correct |
13 |
Correct |
56 ms |
14292 KB |
Output is correct |
14 |
Correct |
63 ms |
14488 KB |
Output is correct |
15 |
Correct |
60 ms |
14488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
13652 KB |
Output is correct |
2 |
Correct |
9 ms |
1792 KB |
Output is correct |
3 |
Correct |
45 ms |
13344 KB |
Output is correct |
4 |
Correct |
71 ms |
15052 KB |
Output is correct |
5 |
Correct |
62 ms |
15272 KB |
Output is correct |
6 |
Correct |
50 ms |
13668 KB |
Output is correct |
7 |
Correct |
51 ms |
13660 KB |
Output is correct |
8 |
Correct |
62 ms |
14340 KB |
Output is correct |
9 |
Correct |
62 ms |
14492 KB |
Output is correct |
10 |
Correct |
60 ms |
14016 KB |
Output is correct |
11 |
Correct |
55 ms |
14204 KB |
Output is correct |
12 |
Correct |
61 ms |
14032 KB |
Output is correct |
13 |
Correct |
56 ms |
14292 KB |
Output is correct |
14 |
Correct |
63 ms |
14488 KB |
Output is correct |
15 |
Correct |
60 ms |
14488 KB |
Output is correct |
16 |
Correct |
46 ms |
12184 KB |
Output is correct |
17 |
Correct |
47 ms |
12024 KB |
Output is correct |
18 |
Correct |
48 ms |
11972 KB |
Output is correct |
19 |
Correct |
48 ms |
12008 KB |
Output is correct |
20 |
Correct |
55 ms |
12804 KB |
Output is correct |
21 |
Correct |
54 ms |
12364 KB |
Output is correct |
22 |
Correct |
56 ms |
14632 KB |
Output is correct |
23 |
Correct |
52 ms |
12144 KB |
Output is correct |
24 |
Correct |
48 ms |
12132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1792 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
11604 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
11752 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |