# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
260842 |
2020-08-11T05:20:17 Z |
반딧불(#5074) |
길고양이 (JOI20_stray) |
C++17 |
|
71 ms |
15908 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 = 0;
else cnt = 2;
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) 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); /// �Ͼ �� ���� ���� �Ͼ��!
}
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; /// ���� �̽�½���� �ϴ� ��� �����Ѵ�.
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
15908 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
15908 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
13796 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
48 ms |
13032 KB |
Output is correct |
4 |
Correct |
63 ms |
15348 KB |
Output is correct |
5 |
Correct |
71 ms |
15552 KB |
Output is correct |
6 |
Incorrect |
49 ms |
13364 KB |
Wrong Answer [6] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
13796 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
48 ms |
13032 KB |
Output is correct |
4 |
Correct |
63 ms |
15348 KB |
Output is correct |
5 |
Correct |
71 ms |
15552 KB |
Output is correct |
6 |
Incorrect |
49 ms |
13364 KB |
Wrong Answer [6] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1792 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
11284 KB |
Output is correct |
2 |
Incorrect |
47 ms |
12120 KB |
Wrong Answer [5] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
11280 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |