답안 #216736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216736 2020-03-28T00:02:29 Z ainta 길고양이 (JOI20_stray) C++17
100 / 100
72 ms 17568 KB
#include "Anthony.h"
#include <vector>
#include <algorithm>
#include <cstdio>
#define N_ 20100
using namespace std;

vector<int>E[N_];
int Q[N_], D[N_], w[6] = { 0,0,1,1,0,1 }, T[N_], Dep[N_], Col[N_], BB;

void DFS(int a, int pp) {
	int c = E[a].size();
	if (a)c--;
	if (c >= 2)T[a] = 0;
	for (auto &x : E[a]) {
		if (x == pp)continue;
		T[x] = T[a] + 1;

		if (a == 0) {
			Col[x] = 1;
		}
		else {
			if (T[a] == 0)Col[x] = !Col[a];
			else Col[x] = w[(T[a] - 1) % 6];
		}

		Dep[x] = Dep[a] + 1;
		DFS(x, a);
	}
}


std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
  std::vector<int> X(M);
  int i;
  BB = B;
  for (i = 0; i < M; i++) {
	  E[U[i]].push_back(V[i]);
	  E[V[i]].push_back(U[i]);
  }
  Dep[0] = 0;
  if (BB) {
	  DFS(0, 0);
	  for (i = 0; i < M; i++) {
		  if (Dep[U[i]] < Dep[V[i]])X[i] = Col[V[i]];
		  else X[i] = Col[U[i]];
	  }
  }
  else {
	  int head = 0, tail = 0;
	  Q[++tail] = 0;
	  for (i = 0; i <= N; i++)D[i] = 1e9;
	  D[0] = 0;
	  while (head < tail) {
		  int x = Q[++head];
		  for (auto &t : E[x]) {
			  if (D[t] > D[x] + 1) {
				  D[t] = D[x] + 1;
				  Q[++tail] = t;
			  }
		  }
	  }
	  for (i = 0; i < M; i++) {
		  X[i] = min(D[U[i]], D[V[i]]) % 3;
	  }
  }
  return X;
}
#include "Catherine.h"
#include <vector>


int s, ok, dd, BBB;
int L[3];
void Init(int A, int B) {
	BBB = B;
	s = 0; L[0] = L[1] = L[2] = -1;
	ok = 0;
	dd = 0;
}
void Put(int a) {
	L[2] = L[1];
	L[1] = L[0];
	L[0] = a;
	s++;
}
int Move(std::vector<int> y) {
	int i;
	if (BBB == 0) {
		if (!y[0]) {
			if (!y[1])return 2;
			return 1;
		}
		if (!y[1]) {
			if (!y[2])return 0;
			return 2;
		}
		if (!y[2]) {
			if (!y[0])return 1;
			return 0;
		}
	}
	if (ok) {
		int x;
		if (!y[0]) x = 1;
		else if (!y[1]) x = 0;
		else  x = !L[0];
		Put(x);
		return x;
	}
	if (!s) {
		if (y[0] + y[1] >= 3) {
			ok = 1;
			if (y[0] == 1) {
				Put(0); return 0;
			}
			if (y[1] == 1) {
				Put(1); return 1;
			}
		}
		if (y[0] + y[1] == 1) {
			ok = 1;
			if (y[0]) {
				Put(0); return 0;
			}
			else {
				Put(1); return 1;
			}
		}
		if (y[1] == 2 || y[0] == 2)dd = 1;
		if (y[1]) {
			Put(1);
			return 1;
		}
		Put(0);
		return 0;
	}
	if (y[0] + y[1] >= 2) {
		ok = 1;
		if (!y[L[0]]) {
			Put(L[0]);
			return -1;
		}
		int x = !L[0];
		Put(x);
		return x;
	}
	if (y[0] + y[1] == 0) {
		ok = 1;
		Put(L[0]);
		return -1;
	}
	int cur = 0;
	if (y[0])cur = 0;
	else cur = 1;
	if (s < 2) {
		Put(cur);
		return cur;
	}
	if (s == 2) {
		if (dd) {
			ok = 1;
			if (L[1] == 0 && L[0] == 0) {
				Put(L[0]);
				return -1;
			}
			if (L[1] == 0) {
				if (cur == 0) {
					Put(cur); return cur;
				}
				else {
					Put(L[0]); return -1;
				}
			}
			else {
				if (cur == 0) {
					Put(cur); return cur;
				}
				else {
					Put(L[0]); return -1;
				}
			}
		}
		if (L[0] == 0) {
			ok = 1;
			if (cur == 1) {
				Put(cur); return cur;
			}
			else {
				Put(L[0]); return -1;
			}
		}
		Put(cur); return cur;
	}
	if (s == 3) {
		ok = 1;
		if (cur == 0) {
			Put(cur); return cur;
		}
		else {
			Put(L[0]); return -1;
		}
	}
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:20:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
Catherine.cpp:136:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 15484 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 51 ms 15576 KB Output is correct
4 Correct 63 ms 17568 KB Output is correct
5 Correct 62 ms 17228 KB Output is correct
6 Correct 52 ms 15880 KB Output is correct
7 Correct 62 ms 16064 KB Output is correct
8 Correct 60 ms 16644 KB Output is correct
9 Correct 60 ms 16672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 15484 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 51 ms 15576 KB Output is correct
4 Correct 63 ms 17568 KB Output is correct
5 Correct 62 ms 17228 KB Output is correct
6 Correct 52 ms 15880 KB Output is correct
7 Correct 62 ms 16064 KB Output is correct
8 Correct 60 ms 16644 KB Output is correct
9 Correct 60 ms 16672 KB Output is correct
10 Correct 48 ms 13932 KB Output is correct
11 Correct 50 ms 13888 KB Output is correct
12 Correct 48 ms 13924 KB Output is correct
13 Correct 49 ms 13932 KB Output is correct
14 Correct 49 ms 14200 KB Output is correct
15 Correct 54 ms 14604 KB Output is correct
16 Correct 56 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 13172 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 44 ms 13144 KB Output is correct
4 Correct 68 ms 15052 KB Output is correct
5 Correct 63 ms 15144 KB Output is correct
6 Correct 53 ms 13652 KB Output is correct
7 Correct 53 ms 13552 KB Output is correct
8 Correct 59 ms 14292 KB Output is correct
9 Correct 56 ms 14492 KB Output is correct
10 Correct 53 ms 14224 KB Output is correct
11 Correct 54 ms 14240 KB Output is correct
12 Correct 55 ms 14248 KB Output is correct
13 Correct 60 ms 14364 KB Output is correct
14 Correct 56 ms 14344 KB Output is correct
15 Correct 59 ms 14340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 13172 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 44 ms 13144 KB Output is correct
4 Correct 68 ms 15052 KB Output is correct
5 Correct 63 ms 15144 KB Output is correct
6 Correct 53 ms 13652 KB Output is correct
7 Correct 53 ms 13552 KB Output is correct
8 Correct 59 ms 14292 KB Output is correct
9 Correct 56 ms 14492 KB Output is correct
10 Correct 53 ms 14224 KB Output is correct
11 Correct 54 ms 14240 KB Output is correct
12 Correct 55 ms 14248 KB Output is correct
13 Correct 60 ms 14364 KB Output is correct
14 Correct 56 ms 14344 KB Output is correct
15 Correct 59 ms 14340 KB Output is correct
16 Correct 46 ms 12236 KB Output is correct
17 Correct 50 ms 12228 KB Output is correct
18 Correct 52 ms 12020 KB Output is correct
19 Correct 48 ms 12024 KB Output is correct
20 Correct 60 ms 12692 KB Output is correct
21 Correct 50 ms 12424 KB Output is correct
22 Correct 57 ms 14620 KB Output is correct
23 Correct 48 ms 12116 KB Output is correct
24 Correct 48 ms 12116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 10 ms 1792 KB Output is correct
4 Correct 11 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 10 ms 1792 KB Output is correct
7 Correct 11 ms 1792 KB Output is correct
8 Correct 10 ms 1792 KB Output is correct
9 Correct 10 ms 1916 KB Output is correct
10 Correct 10 ms 1792 KB Output is correct
11 Correct 10 ms 1792 KB Output is correct
12 Correct 12 ms 1792 KB Output is correct
13 Correct 10 ms 1536 KB Output is correct
14 Correct 10 ms 1792 KB Output is correct
15 Correct 10 ms 1792 KB Output is correct
16 Correct 10 ms 1536 KB Output is correct
17 Correct 12 ms 1536 KB Output is correct
18 Correct 10 ms 1536 KB Output is correct
19 Correct 10 ms 1536 KB Output is correct
20 Correct 10 ms 1548 KB Output is correct
21 Correct 10 ms 1792 KB Output is correct
22 Correct 12 ms 1536 KB Output is correct
23 Correct 10 ms 1536 KB Output is correct
24 Correct 10 ms 1536 KB Output is correct
25 Correct 10 ms 1536 KB Output is correct
26 Correct 10 ms 1536 KB Output is correct
27 Correct 10 ms 1536 KB Output is correct
28 Correct 10 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 11404 KB Output is correct
2 Correct 55 ms 12508 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 41 ms 11520 KB Output is correct
5 Correct 63 ms 13828 KB Output is correct
6 Correct 60 ms 14064 KB Output is correct
7 Correct 54 ms 12932 KB Output is correct
8 Correct 48 ms 13156 KB Output is correct
9 Correct 61 ms 13816 KB Output is correct
10 Correct 61 ms 13812 KB Output is correct
11 Correct 67 ms 13956 KB Output is correct
12 Correct 61 ms 13948 KB Output is correct
13 Correct 62 ms 14072 KB Output is correct
14 Correct 61 ms 14072 KB Output is correct
15 Correct 59 ms 13812 KB Output is correct
16 Correct 59 ms 14052 KB Output is correct
17 Correct 55 ms 13564 KB Output is correct
18 Correct 56 ms 13816 KB Output is correct
19 Correct 60 ms 13692 KB Output is correct
20 Correct 55 ms 13568 KB Output is correct
21 Correct 59 ms 13824 KB Output is correct
22 Correct 57 ms 13564 KB Output is correct
23 Correct 48 ms 11440 KB Output is correct
24 Correct 47 ms 11416 KB Output is correct
25 Correct 49 ms 11844 KB Output is correct
26 Correct 47 ms 11844 KB Output is correct
27 Correct 64 ms 12640 KB Output is correct
28 Correct 54 ms 12648 KB Output is correct
29 Correct 57 ms 12668 KB Output is correct
30 Correct 64 ms 12752 KB Output is correct
31 Correct 50 ms 11340 KB Output is correct
32 Correct 55 ms 11444 KB Output is correct
33 Correct 61 ms 11828 KB Output is correct
34 Correct 48 ms 11824 KB Output is correct
35 Correct 54 ms 12436 KB Output is correct
36 Correct 52 ms 12440 KB Output is correct
37 Correct 55 ms 12440 KB Output is correct
38 Correct 54 ms 12444 KB Output is correct
39 Correct 52 ms 12680 KB Output is correct
40 Correct 61 ms 12444 KB Output is correct
41 Correct 55 ms 13168 KB Output is correct
42 Correct 55 ms 13160 KB Output is correct
43 Correct 54 ms 13156 KB Output is correct
44 Correct 59 ms 13208 KB Output is correct
45 Correct 56 ms 13292 KB Output is correct
46 Correct 65 ms 13172 KB Output is correct
47 Correct 54 ms 12356 KB Output is correct
48 Correct 52 ms 12284 KB Output is correct
49 Correct 51 ms 12372 KB Output is correct
50 Correct 52 ms 12516 KB Output is correct
51 Correct 56 ms 11864 KB Output is correct
52 Correct 49 ms 11728 KB Output is correct
53 Correct 48 ms 11728 KB Output is correct
54 Correct 48 ms 11864 KB Output is correct
55 Correct 51 ms 11796 KB Output is correct
56 Correct 47 ms 11728 KB Output is correct
57 Correct 49 ms 11612 KB Output is correct
58 Correct 55 ms 11584 KB Output is correct
59 Correct 48 ms 11980 KB Output is correct
60 Correct 52 ms 11824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 11416 KB Output is correct
2 Correct 52 ms 12364 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Correct 46 ms 11268 KB Output is correct
5 Correct 72 ms 14172 KB Output is correct
6 Correct 55 ms 14072 KB Output is correct
7 Correct 49 ms 13052 KB Output is correct
8 Correct 52 ms 13300 KB Output is correct
9 Correct 65 ms 14048 KB Output is correct
10 Correct 57 ms 14056 KB Output is correct
11 Correct 56 ms 14084 KB Output is correct
12 Correct 61 ms 14204 KB Output is correct
13 Correct 62 ms 13956 KB Output is correct
14 Correct 60 ms 13948 KB Output is correct
15 Correct 56 ms 13820 KB Output is correct
16 Correct 57 ms 14064 KB Output is correct
17 Correct 54 ms 13564 KB Output is correct
18 Correct 59 ms 13624 KB Output is correct
19 Correct 55 ms 13564 KB Output is correct
20 Correct 55 ms 13572 KB Output is correct
21 Correct 55 ms 13816 KB Output is correct
22 Correct 54 ms 13556 KB Output is correct
23 Correct 46 ms 11388 KB Output is correct
24 Correct 46 ms 11440 KB Output is correct
25 Correct 49 ms 11976 KB Output is correct
26 Correct 47 ms 11980 KB Output is correct
27 Correct 54 ms 12640 KB Output is correct
28 Correct 56 ms 12640 KB Output is correct
29 Correct 56 ms 12616 KB Output is correct
30 Correct 53 ms 12724 KB Output is correct
31 Correct 47 ms 11452 KB Output is correct
32 Correct 46 ms 11576 KB Output is correct
33 Correct 50 ms 11968 KB Output is correct
34 Correct 49 ms 11968 KB Output is correct
35 Correct 52 ms 12436 KB Output is correct
36 Correct 53 ms 12452 KB Output is correct
37 Correct 52 ms 12444 KB Output is correct
38 Correct 55 ms 12688 KB Output is correct
39 Correct 52 ms 12448 KB Output is correct
40 Correct 52 ms 12436 KB Output is correct
41 Correct 54 ms 13172 KB Output is correct
42 Correct 54 ms 13084 KB Output is correct
43 Correct 54 ms 13144 KB Output is correct
44 Correct 55 ms 13272 KB Output is correct
45 Correct 55 ms 13300 KB Output is correct
46 Correct 55 ms 13296 KB Output is correct
47 Correct 52 ms 12336 KB Output is correct
48 Correct 51 ms 12368 KB Output is correct
49 Correct 51 ms 12364 KB Output is correct
50 Correct 51 ms 12492 KB Output is correct
51 Correct 49 ms 11652 KB Output is correct
52 Correct 47 ms 11732 KB Output is correct
53 Correct 48 ms 11848 KB Output is correct
54 Correct 47 ms 11832 KB Output is correct
55 Correct 50 ms 11700 KB Output is correct
56 Correct 47 ms 11856 KB Output is correct
57 Correct 48 ms 11616 KB Output is correct
58 Correct 50 ms 11604 KB Output is correct
59 Correct 47 ms 11848 KB Output is correct
60 Correct 49 ms 11708 KB Output is correct