#include "Anthony.h"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
using pii = pair<int, int>;
namespace {
vector<int> magic;
vector<vector<pii>> g;
vector<int> ans;
} // namespace
void dfs(int now, int p, int top, int len){
int cnt = 0;
for(pii i : g[now]){
if(i.F == p) continue;
cnt++;
}
int nxt = !top;
if(cnt == 1){
if(len == -1){
if(top == 0) len = 0;
else len = 1;
}
len++;
//cerr << "two " << now << " " << len << "\n";
nxt = magic[len % 6];
}
else len = -1;
for(pii i : g[now]){
if(i.F == p) continue;
ans[i.S] = nxt;
dfs(i.F, now, nxt, len);
}
}
vector<int> Mark(int n, int m, int A, int B,
vector<int> U, vector<int> V) {
magic = {0, 1, 0, 0, 1, 1};
ans.resize(m);
g.resize(n);
for(int i = 0; i < m; i++){
int u = U[i], v = V[i];
g[u].eb(mp(v, i));
g[v].eb(mp(u, i));
}
dfs(0, 0, 1, -1);
//printv(ans, cerr);
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
namespace {
int A, B;
int lst = -1;
vector<int> magic;
deque<int> tmp;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
magic = {0, 1, 0, 0, 1, 1};
}
bool check(){
while(tmp.size() > 5) tmp.pop_front();
if(tmp.size() < 5) return false;
for(int i = 0; i < 6; i++){
bool ok = true;
for(int j = 0; j < 5; j++){
if(tmp[j] != magic[(i + j) % 6]) ok = false;
}
if(ok) return true;
}
return false;
}
int Move(vector<int> y) {
if(lst != -1) y[lst]++;
int deg = 0;
for(int i : y) deg += i;
if(deg >= 3){
int r;
for(int i = 0; i < 2; i++){
if(y[i] != 1) continue;
if(i == lst) r = -1;
else r = lst = i;
}
tmp.clear();
tmp.eb(lst);
//cerr << "test " << r << "\n";
return r;
}
int nxt = -1;
if(lst != -1) y[lst]--;
for(int i = 0; i < 2; i++){
if(y[i]){
nxt = i;
//break;
}
}
if(lst == -1){
y[nxt]--;
for(int i = 0; i < 2; i++){
if(y[i]){
tmp.eb(i);
}
}
}
tmp.eb(nxt);
//cerr << "check ";
//printv(tmp, cerr);
if(check()){
tmp.clear();
tmp.eb(lst);
return -1;
}
lst = nxt;
//cerr << nxt << "\n";
return nxt;
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:54:13: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
54 | int r;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
15820 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
31 ms |
14740 KB |
Output is correct |
4 |
Correct |
46 ms |
17140 KB |
Output is correct |
5 |
Correct |
53 ms |
17276 KB |
Output is correct |
6 |
Correct |
39 ms |
15240 KB |
Output is correct |
7 |
Incorrect |
34 ms |
15260 KB |
Wrong Answer [6] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
15820 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
31 ms |
14740 KB |
Output is correct |
4 |
Correct |
46 ms |
17140 KB |
Output is correct |
5 |
Correct |
53 ms |
17276 KB |
Output is correct |
6 |
Correct |
39 ms |
15240 KB |
Output is correct |
7 |
Incorrect |
34 ms |
15260 KB |
Wrong Answer [6] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
13464 KB |
Output is correct |
2 |
Correct |
1 ms |
488 KB |
Output is correct |
3 |
Correct |
41 ms |
12520 KB |
Output is correct |
4 |
Correct |
48 ms |
15068 KB |
Output is correct |
5 |
Correct |
45 ms |
15180 KB |
Output is correct |
6 |
Correct |
41 ms |
13052 KB |
Output is correct |
7 |
Incorrect |
37 ms |
13144 KB |
Wrong Answer [6] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
13464 KB |
Output is correct |
2 |
Correct |
1 ms |
488 KB |
Output is correct |
3 |
Correct |
41 ms |
12520 KB |
Output is correct |
4 |
Correct |
48 ms |
15068 KB |
Output is correct |
5 |
Correct |
45 ms |
15180 KB |
Output is correct |
6 |
Correct |
41 ms |
13052 KB |
Output is correct |
7 |
Incorrect |
37 ms |
13144 KB |
Wrong Answer [6] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
872 KB |
Output is correct |
2 |
Correct |
1 ms |
504 KB |
Output is correct |
3 |
Correct |
1 ms |
872 KB |
Output is correct |
4 |
Correct |
2 ms |
872 KB |
Output is correct |
5 |
Correct |
3 ms |
872 KB |
Output is correct |
6 |
Correct |
2 ms |
872 KB |
Output is correct |
7 |
Correct |
2 ms |
872 KB |
Output is correct |
8 |
Correct |
2 ms |
880 KB |
Output is correct |
9 |
Correct |
2 ms |
880 KB |
Output is correct |
10 |
Correct |
2 ms |
872 KB |
Output is correct |
11 |
Correct |
2 ms |
872 KB |
Output is correct |
12 |
Correct |
2 ms |
872 KB |
Output is correct |
13 |
Correct |
1 ms |
872 KB |
Output is correct |
14 |
Correct |
1 ms |
876 KB |
Output is correct |
15 |
Correct |
2 ms |
880 KB |
Output is correct |
16 |
Correct |
2 ms |
872 KB |
Output is correct |
17 |
Correct |
2 ms |
884 KB |
Output is correct |
18 |
Correct |
2 ms |
872 KB |
Output is correct |
19 |
Correct |
2 ms |
872 KB |
Output is correct |
20 |
Correct |
2 ms |
872 KB |
Output is correct |
21 |
Correct |
2 ms |
868 KB |
Output is correct |
22 |
Correct |
1 ms |
880 KB |
Output is correct |
23 |
Correct |
2 ms |
872 KB |
Output is correct |
24 |
Correct |
1 ms |
880 KB |
Output is correct |
25 |
Correct |
2 ms |
884 KB |
Output is correct |
26 |
Correct |
2 ms |
824 KB |
Output is correct |
27 |
Correct |
2 ms |
880 KB |
Output is correct |
28 |
Correct |
2 ms |
872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
11072 KB |
Output is correct |
2 |
Correct |
48 ms |
12260 KB |
Output is correct |
3 |
Correct |
0 ms |
492 KB |
Output is correct |
4 |
Correct |
25 ms |
11004 KB |
Output is correct |
5 |
Correct |
51 ms |
13440 KB |
Output is correct |
6 |
Correct |
54 ms |
13600 KB |
Output is correct |
7 |
Correct |
44 ms |
12660 KB |
Output is correct |
8 |
Correct |
33 ms |
12572 KB |
Output is correct |
9 |
Correct |
48 ms |
13432 KB |
Output is correct |
10 |
Correct |
43 ms |
13492 KB |
Output is correct |
11 |
Correct |
40 ms |
13420 KB |
Output is correct |
12 |
Correct |
55 ms |
13568 KB |
Output is correct |
13 |
Correct |
57 ms |
13404 KB |
Output is correct |
14 |
Correct |
48 ms |
13472 KB |
Output is correct |
15 |
Correct |
39 ms |
13520 KB |
Output is correct |
16 |
Correct |
58 ms |
13404 KB |
Output is correct |
17 |
Correct |
52 ms |
13240 KB |
Output is correct |
18 |
Correct |
44 ms |
13184 KB |
Output is correct |
19 |
Correct |
40 ms |
13100 KB |
Output is correct |
20 |
Correct |
47 ms |
13108 KB |
Output is correct |
21 |
Correct |
41 ms |
13204 KB |
Output is correct |
22 |
Correct |
45 ms |
13260 KB |
Output is correct |
23 |
Correct |
31 ms |
11212 KB |
Output is correct |
24 |
Correct |
31 ms |
11160 KB |
Output is correct |
25 |
Correct |
45 ms |
11572 KB |
Output is correct |
26 |
Correct |
33 ms |
11568 KB |
Output is correct |
27 |
Correct |
45 ms |
12424 KB |
Output is correct |
28 |
Correct |
35 ms |
12320 KB |
Output is correct |
29 |
Correct |
36 ms |
12328 KB |
Output is correct |
30 |
Correct |
49 ms |
12336 KB |
Output is correct |
31 |
Correct |
32 ms |
11320 KB |
Output is correct |
32 |
Correct |
30 ms |
11236 KB |
Output is correct |
33 |
Correct |
32 ms |
11532 KB |
Output is correct |
34 |
Correct |
45 ms |
11544 KB |
Output is correct |
35 |
Correct |
40 ms |
12184 KB |
Output is correct |
36 |
Correct |
47 ms |
12184 KB |
Output is correct |
37 |
Correct |
48 ms |
12220 KB |
Output is correct |
38 |
Correct |
37 ms |
12332 KB |
Output is correct |
39 |
Correct |
33 ms |
12216 KB |
Output is correct |
40 |
Correct |
37 ms |
12184 KB |
Output is correct |
41 |
Correct |
48 ms |
12784 KB |
Output is correct |
42 |
Correct |
53 ms |
12788 KB |
Output is correct |
43 |
Correct |
38 ms |
12792 KB |
Output is correct |
44 |
Correct |
44 ms |
12944 KB |
Output is correct |
45 |
Correct |
39 ms |
12840 KB |
Output is correct |
46 |
Correct |
41 ms |
12964 KB |
Output is correct |
47 |
Correct |
36 ms |
12124 KB |
Output is correct |
48 |
Correct |
35 ms |
12116 KB |
Output is correct |
49 |
Correct |
35 ms |
11972 KB |
Output is correct |
50 |
Correct |
34 ms |
12108 KB |
Output is correct |
51 |
Correct |
31 ms |
11396 KB |
Output is correct |
52 |
Correct |
37 ms |
11444 KB |
Output is correct |
53 |
Correct |
31 ms |
11432 KB |
Output is correct |
54 |
Correct |
31 ms |
11372 KB |
Output is correct |
55 |
Correct |
30 ms |
11492 KB |
Output is correct |
56 |
Correct |
34 ms |
11476 KB |
Output is correct |
57 |
Correct |
36 ms |
11216 KB |
Output is correct |
58 |
Correct |
33 ms |
11440 KB |
Output is correct |
59 |
Correct |
31 ms |
11312 KB |
Output is correct |
60 |
Correct |
35 ms |
11260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
11312 KB |
Output is correct |
2 |
Correct |
37 ms |
12184 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
25 ms |
11016 KB |
Output is correct |
5 |
Correct |
40 ms |
13544 KB |
Output is correct |
6 |
Correct |
41 ms |
13596 KB |
Output is correct |
7 |
Correct |
37 ms |
12688 KB |
Output is correct |
8 |
Correct |
32 ms |
13008 KB |
Output is correct |
9 |
Correct |
52 ms |
13932 KB |
Output is correct |
10 |
Correct |
44 ms |
14012 KB |
Output is correct |
11 |
Correct |
43 ms |
14028 KB |
Output is correct |
12 |
Correct |
44 ms |
13904 KB |
Output is correct |
13 |
Correct |
44 ms |
13872 KB |
Output is correct |
14 |
Correct |
51 ms |
13932 KB |
Output is correct |
15 |
Correct |
40 ms |
13912 KB |
Output is correct |
16 |
Correct |
41 ms |
13836 KB |
Output is correct |
17 |
Correct |
40 ms |
13620 KB |
Output is correct |
18 |
Correct |
38 ms |
13624 KB |
Output is correct |
19 |
Correct |
36 ms |
13712 KB |
Output is correct |
20 |
Correct |
39 ms |
13584 KB |
Output is correct |
21 |
Correct |
40 ms |
13604 KB |
Output is correct |
22 |
Correct |
35 ms |
13728 KB |
Output is correct |
23 |
Correct |
30 ms |
11624 KB |
Output is correct |
24 |
Correct |
31 ms |
11840 KB |
Output is correct |
25 |
Correct |
32 ms |
12056 KB |
Output is correct |
26 |
Correct |
33 ms |
12004 KB |
Output is correct |
27 |
Correct |
38 ms |
12804 KB |
Output is correct |
28 |
Correct |
39 ms |
12776 KB |
Output is correct |
29 |
Correct |
40 ms |
12748 KB |
Output is correct |
30 |
Correct |
38 ms |
12732 KB |
Output is correct |
31 |
Correct |
30 ms |
11684 KB |
Output is correct |
32 |
Correct |
37 ms |
11628 KB |
Output is correct |
33 |
Correct |
32 ms |
12044 KB |
Output is correct |
34 |
Correct |
32 ms |
12028 KB |
Output is correct |
35 |
Correct |
40 ms |
12660 KB |
Output is correct |
36 |
Correct |
38 ms |
12764 KB |
Output is correct |
37 |
Correct |
37 ms |
12604 KB |
Output is correct |
38 |
Correct |
37 ms |
12672 KB |
Output is correct |
39 |
Correct |
36 ms |
12660 KB |
Output is correct |
40 |
Correct |
35 ms |
12680 KB |
Output is correct |
41 |
Correct |
45 ms |
13272 KB |
Output is correct |
42 |
Correct |
47 ms |
13196 KB |
Output is correct |
43 |
Correct |
48 ms |
13276 KB |
Output is correct |
44 |
Correct |
41 ms |
13156 KB |
Output is correct |
45 |
Correct |
37 ms |
13312 KB |
Output is correct |
46 |
Correct |
36 ms |
13220 KB |
Output is correct |
47 |
Correct |
33 ms |
12636 KB |
Output is correct |
48 |
Correct |
39 ms |
12520 KB |
Output is correct |
49 |
Correct |
35 ms |
12404 KB |
Output is correct |
50 |
Correct |
36 ms |
12524 KB |
Output is correct |
51 |
Correct |
31 ms |
11828 KB |
Output is correct |
52 |
Correct |
44 ms |
11724 KB |
Output is correct |
53 |
Correct |
38 ms |
11944 KB |
Output is correct |
54 |
Correct |
30 ms |
11840 KB |
Output is correct |
55 |
Correct |
33 ms |
11700 KB |
Output is correct |
56 |
Correct |
31 ms |
11832 KB |
Output is correct |
57 |
Correct |
35 ms |
11700 KB |
Output is correct |
58 |
Correct |
34 ms |
11660 KB |
Output is correct |
59 |
Correct |
31 ms |
11788 KB |
Output is correct |
60 |
Correct |
30 ms |
11888 KB |
Output is correct |