# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
260844 |
2020-08-11T05:25:05 Z |
반딧불(#5074) |
Stray Cat (JOI20_stray) |
C++17 |
|
77 ms |
16336 KB |
#include <bits/stdc++.h>
#include "Anthony.h"
using namespace std;
namespace {
int n, k;
vector<pair<int, int> > link[20002];
int col[20002];
int road[20002];
const int s[6] = {0, 0, 1, 0, 1, 1};
void dfs(int x, int par = -1, int cnt = 0){
if(par == -1){
for(auto &y: link[x]){
col[y.second] = s[cnt];
road[y.first] = y.second;
dfs(y.first, x, (cnt+1)%6);
}
return;
}
if((int)link[x].size() == 1) return;
if((int)link[x].size() == 2){
for(auto &y: link[x]){
if(par == y.first) continue;
col[y.second] = s[cnt];
road[y.first] = y.second;
dfs(y.first, x, (cnt+1)%6);
}
return;
}
if(col[road[x]]) cnt = 1;
else cnt = 3;
for(auto &y: link[x]){
if(par == y.first) continue;
col[y.second] = !col[road[x]];
road[y.first] = y.second;
dfs(y.first, x, cnt);
}
}
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
n = N;
k = M;
for(int i=0; i<k; i++){
link[U[i]].push_back(make_pair(V[i], i));
link[V[i]].push_back(make_pair(U[i], i));
}
dfs(0);
return vector<int>(col, col+k);
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
namespace {
int a, b;
int prv = -1;
bool strange = 1;
int cnt = 0;
int s[] = {1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0};
vector<int> vb;
}
void Init(int A, int B) {
a = A;
b = B;
prv = -1, strange = 1;
}
int Move(vector<int> y) {
int c0 = y[0];
int c1 = y[1];
cnt++;
if(cnt > 6) strange = 0;
if(!strange){
if(!c0) return prv = 1;
if(!c1) return prv = 0;
if(prv == 0) c0++;
if(prv == 1) c1++;
if(c0 == 1) return prv = 0;
if(c1 == 1) return prv = 1;
fprintf(stderr, "nowhere to go; c0 >= 2, c1 >= 2");
exit(1);
}
else{
if(prv == 0) c0++;
if(prv == 1) c1++;
if(prv == -1){ /// ù ���� ���
if(c0 + c1 == 1){ /// �� ���� ��ۿ� ���� ���
strange = 0; /// ���� ���� ��������.
if(c0) return prv = 0; /// �װ� 0�̸� 0���� ����.
if(c1) return prv = 1; /// �װ� 1�̸� 1�� ����.
fprintf(stderr, "c0 + c1 == 1 but what is 1?");
exit(1); /// �Ͼ �� ���� ���� �Ͼ��!
}
if(c0 + c1 > 2){ /// ���� ���� ���� ���
strange = 0; /// ���� ��������!
if(c0 == 1) return prv = 0; /// 0�� 1���ۿ� ������ 0���� ����.
if(c1 == 1) return prv = 1; /// 1�� 1���ۿ� ������ 1�� ����.
fprintf(stderr, "c0 + c1 > 2 but what is 1?");
exit(1); /// �Ͼ �� ���� ���� �Ͼ��!
}
/// ���� c0 + c1 = 2�̴�.
if(c0 == 2){
vb.push_back(0);
vb.push_back(0);
return prv = 0; /// �� �� 0�̴ϱ� �׳� 0���� ����.
}
else if(c1 == 2){
vb.push_back(1);
vb.push_back(1);
return prv = 1; /// �� �� 1�̴ϱ� �׳� 1�� ����.
}
else{
vb.push_back(0);
vb.push_back(1);
return prv = 1; /// �׳� 1�� ����.
}
}
/// ù ���� �ƴ����� ������ �̽�½���� ���� �ִ� ����̴�.
if(c0 + c1 > 2){ /// ���� ���� ���� ���
strange = 0; /// ���� ��������!
if(c0 == 1){
if(prv == 0) return -1; /// �ǵ��ư���.
return prv = 0; /// 0�� 1���ۿ� ������ 0���� ����.
}
if(c1 == 1){
if(prv == 1) return -1; /// �ǵ��ư���.
return prv = 1; /// 1�� 1���ۿ� ������ 1�� ����.
}
fprintf(stderr, "c0 + c1 > 2 but what is 1?");
exit(1); /// �Ͼ �� ���� ���� �Ͼ��!
}
if(c0 + c1 == 1){ /// ���ٸ� ���� ���
strange = 0; /// �츮 ������ Ʋ������ ���ư���!
return -1;
}
/// ���� �̽�½����, ������ ������ �ڽ���.
vb.push_back(y[0] ? 0 : 1); /// �ϴ� vb �ڿ� ���� �� �ִ� ���� �߰��Ѵ�.
// for(auto &x: vb) printf("%d ", x);
// puts("");
bool possible = 0;
for(int i=0; i<6; i++){ /// ���� ��Ȳ�� �������� �Ǻ��Ѵ�.
bool different = 0;
for(int j=0; j<(int)vb.size(); j++){
if(s[i+j] != vb[j]){
different = 1;
break;
}
}
if(!different){
possible = 1;
break;
}
}
if(!possible){
strange = 0; /// ���� ��Ȳ�� �Ұ����ߴ�!
return -1; /// �ǵ��ư���.
}
return prv = y[0] ? 0 : 1; /// ���� �̽�½���� �ϴ� ��� �����Ѵ�.
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
16336 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
16336 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
13912 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
41 ms |
13044 KB |
Output is correct |
4 |
Correct |
77 ms |
15348 KB |
Output is correct |
5 |
Correct |
65 ms |
15560 KB |
Output is correct |
6 |
Incorrect |
43 ms |
13492 KB |
Wrong Answer [6] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
13912 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
41 ms |
13044 KB |
Output is correct |
4 |
Correct |
77 ms |
15348 KB |
Output is correct |
5 |
Correct |
65 ms |
15560 KB |
Output is correct |
6 |
Incorrect |
43 ms |
13492 KB |
Wrong Answer [6] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1792 KB |
Output is correct |
5 |
Correct |
3 ms |
1792 KB |
Output is correct |
6 |
Correct |
2 ms |
1792 KB |
Output is correct |
7 |
Correct |
2 ms |
1792 KB |
Output is correct |
8 |
Correct |
2 ms |
1792 KB |
Output is correct |
9 |
Correct |
2 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
1792 KB |
Output is correct |
11 |
Correct |
2 ms |
1792 KB |
Output is correct |
12 |
Correct |
2 ms |
1792 KB |
Output is correct |
13 |
Correct |
2 ms |
1792 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
1792 KB |
Output is correct |
16 |
Correct |
2 ms |
1792 KB |
Output is correct |
17 |
Correct |
3 ms |
1536 KB |
Output is correct |
18 |
Correct |
3 ms |
1792 KB |
Output is correct |
19 |
Correct |
2 ms |
1536 KB |
Output is correct |
20 |
Correct |
2 ms |
1548 KB |
Output is correct |
21 |
Correct |
2 ms |
1792 KB |
Output is correct |
22 |
Correct |
2 ms |
1792 KB |
Output is correct |
23 |
Correct |
4 ms |
1792 KB |
Output is correct |
24 |
Correct |
2 ms |
1536 KB |
Output is correct |
25 |
Correct |
2 ms |
1536 KB |
Output is correct |
26 |
Correct |
2 ms |
1792 KB |
Output is correct |
27 |
Correct |
2 ms |
1792 KB |
Output is correct |
28 |
Correct |
3 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
11392 KB |
Output is correct |
2 |
Correct |
53 ms |
12532 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
44 ms |
11376 KB |
Output is correct |
5 |
Correct |
60 ms |
14032 KB |
Output is correct |
6 |
Correct |
60 ms |
13812 KB |
Output is correct |
7 |
Correct |
45 ms |
13124 KB |
Output is correct |
8 |
Correct |
45 ms |
13396 KB |
Output is correct |
9 |
Correct |
55 ms |
14532 KB |
Output is correct |
10 |
Correct |
54 ms |
14412 KB |
Output is correct |
11 |
Correct |
58 ms |
14528 KB |
Output is correct |
12 |
Correct |
57 ms |
14292 KB |
Output is correct |
13 |
Correct |
54 ms |
14412 KB |
Output is correct |
14 |
Correct |
58 ms |
14548 KB |
Output is correct |
15 |
Correct |
56 ms |
14268 KB |
Output is correct |
16 |
Correct |
66 ms |
14476 KB |
Output is correct |
17 |
Correct |
51 ms |
13908 KB |
Output is correct |
18 |
Correct |
52 ms |
14280 KB |
Output is correct |
19 |
Correct |
52 ms |
13908 KB |
Output is correct |
20 |
Correct |
53 ms |
14116 KB |
Output is correct |
21 |
Correct |
53 ms |
14144 KB |
Output is correct |
22 |
Correct |
51 ms |
14028 KB |
Output is correct |
23 |
Correct |
43 ms |
11920 KB |
Output is correct |
24 |
Correct |
45 ms |
12112 KB |
Output is correct |
25 |
Correct |
44 ms |
12372 KB |
Output is correct |
26 |
Correct |
43 ms |
12496 KB |
Output is correct |
27 |
Correct |
52 ms |
13096 KB |
Output is correct |
28 |
Correct |
50 ms |
13028 KB |
Output is correct |
29 |
Correct |
50 ms |
13012 KB |
Output is correct |
30 |
Correct |
56 ms |
13248 KB |
Output is correct |
31 |
Correct |
44 ms |
12068 KB |
Output is correct |
32 |
Correct |
48 ms |
12056 KB |
Output is correct |
33 |
Correct |
49 ms |
12344 KB |
Output is correct |
34 |
Correct |
44 ms |
12240 KB |
Output is correct |
35 |
Correct |
52 ms |
13068 KB |
Output is correct |
36 |
Correct |
56 ms |
13004 KB |
Output is correct |
37 |
Correct |
51 ms |
13068 KB |
Output is correct |
38 |
Correct |
52 ms |
13060 KB |
Output is correct |
39 |
Correct |
56 ms |
13072 KB |
Output is correct |
40 |
Correct |
52 ms |
13060 KB |
Output is correct |
41 |
Correct |
54 ms |
13396 KB |
Output is correct |
42 |
Correct |
56 ms |
13556 KB |
Output is correct |
43 |
Correct |
55 ms |
13560 KB |
Output is correct |
44 |
Correct |
53 ms |
13572 KB |
Output is correct |
45 |
Correct |
52 ms |
13572 KB |
Output is correct |
46 |
Correct |
51 ms |
13572 KB |
Output is correct |
47 |
Correct |
48 ms |
12756 KB |
Output is correct |
48 |
Correct |
48 ms |
12924 KB |
Output is correct |
49 |
Correct |
57 ms |
12620 KB |
Output is correct |
50 |
Correct |
55 ms |
13000 KB |
Output is correct |
51 |
Correct |
45 ms |
12124 KB |
Output is correct |
52 |
Correct |
54 ms |
12264 KB |
Output is correct |
53 |
Correct |
49 ms |
12124 KB |
Output is correct |
54 |
Correct |
46 ms |
12136 KB |
Output is correct |
55 |
Correct |
50 ms |
12152 KB |
Output is correct |
56 |
Correct |
44 ms |
12264 KB |
Output is correct |
57 |
Correct |
44 ms |
12116 KB |
Output is correct |
58 |
Correct |
43 ms |
12116 KB |
Output is correct |
59 |
Correct |
46 ms |
12116 KB |
Output is correct |
60 |
Correct |
48 ms |
12172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11260 KB |
Output is correct |
2 |
Correct |
48 ms |
12412 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
37 ms |
11384 KB |
Output is correct |
5 |
Correct |
55 ms |
13936 KB |
Output is correct |
6 |
Correct |
56 ms |
13920 KB |
Output is correct |
7 |
Correct |
46 ms |
13052 KB |
Output is correct |
8 |
Correct |
47 ms |
13760 KB |
Output is correct |
9 |
Correct |
54 ms |
14292 KB |
Output is correct |
10 |
Correct |
59 ms |
14288 KB |
Output is correct |
11 |
Correct |
58 ms |
14284 KB |
Output is correct |
12 |
Correct |
55 ms |
14284 KB |
Output is correct |
13 |
Correct |
55 ms |
14420 KB |
Output is correct |
14 |
Correct |
56 ms |
14292 KB |
Output is correct |
15 |
Correct |
54 ms |
14412 KB |
Output is correct |
16 |
Correct |
57 ms |
14660 KB |
Output is correct |
17 |
Correct |
52 ms |
14148 KB |
Output is correct |
18 |
Correct |
52 ms |
14136 KB |
Output is correct |
19 |
Correct |
53 ms |
13900 KB |
Output is correct |
20 |
Correct |
51 ms |
14152 KB |
Output is correct |
21 |
Correct |
52 ms |
13908 KB |
Output is correct |
22 |
Correct |
56 ms |
14028 KB |
Output is correct |
23 |
Correct |
44 ms |
11728 KB |
Output is correct |
24 |
Correct |
43 ms |
11980 KB |
Output is correct |
25 |
Correct |
46 ms |
12480 KB |
Output is correct |
26 |
Correct |
45 ms |
12488 KB |
Output is correct |
27 |
Correct |
51 ms |
13012 KB |
Output is correct |
28 |
Correct |
52 ms |
13012 KB |
Output is correct |
29 |
Correct |
56 ms |
13076 KB |
Output is correct |
30 |
Correct |
54 ms |
13248 KB |
Output is correct |
31 |
Correct |
46 ms |
11988 KB |
Output is correct |
32 |
Correct |
47 ms |
11972 KB |
Output is correct |
33 |
Correct |
46 ms |
12456 KB |
Output is correct |
34 |
Correct |
46 ms |
12332 KB |
Output is correct |
35 |
Correct |
55 ms |
12876 KB |
Output is correct |
36 |
Correct |
55 ms |
12884 KB |
Output is correct |
37 |
Correct |
48 ms |
12884 KB |
Output is correct |
38 |
Correct |
51 ms |
13060 KB |
Output is correct |
39 |
Correct |
49 ms |
13076 KB |
Output is correct |
40 |
Correct |
50 ms |
13072 KB |
Output is correct |
41 |
Correct |
50 ms |
13396 KB |
Output is correct |
42 |
Correct |
50 ms |
13396 KB |
Output is correct |
43 |
Correct |
51 ms |
13692 KB |
Output is correct |
44 |
Correct |
53 ms |
13664 KB |
Output is correct |
45 |
Correct |
52 ms |
13708 KB |
Output is correct |
46 |
Correct |
53 ms |
13524 KB |
Output is correct |
47 |
Correct |
47 ms |
13004 KB |
Output is correct |
48 |
Correct |
48 ms |
13004 KB |
Output is correct |
49 |
Correct |
46 ms |
12748 KB |
Output is correct |
50 |
Correct |
49 ms |
13128 KB |
Output is correct |
51 |
Correct |
44 ms |
12116 KB |
Output is correct |
52 |
Correct |
43 ms |
11988 KB |
Output is correct |
53 |
Correct |
45 ms |
12124 KB |
Output is correct |
54 |
Correct |
45 ms |
12148 KB |
Output is correct |
55 |
Correct |
44 ms |
12140 KB |
Output is correct |
56 |
Correct |
45 ms |
12056 KB |
Output is correct |
57 |
Correct |
48 ms |
12272 KB |
Output is correct |
58 |
Correct |
48 ms |
12104 KB |
Output is correct |
59 |
Correct |
44 ms |
12116 KB |
Output is correct |
60 |
Correct |
43 ms |
12304 KB |
Output is correct |