Submission #216735

# Submission time Handle Problem Language Result Execution time Memory
216735 2020-03-28T00:00:19 Z ainta Stray Cat (JOI20_stray) C++17
85 / 100
63 ms 15748 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])return 1;
		if (!y[1])return 2;
		if (!y[2])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:127:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 15748 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 15748 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 13736 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 13736 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 10 ms 1792 KB Output is correct
8 Correct 10 ms 1792 KB Output is correct
9 Correct 10 ms 1792 KB Output is correct
10 Correct 11 ms 1792 KB Output is correct
11 Correct 11 ms 1792 KB Output is correct
12 Correct 10 ms 1792 KB Output is correct
13 Correct 11 ms 1792 KB Output is correct
14 Correct 11 ms 1792 KB Output is correct
15 Correct 10 ms 1792 KB Output is correct
16 Correct 11 ms 1536 KB Output is correct
17 Correct 10 ms 1564 KB Output is correct
18 Correct 10 ms 1792 KB Output is correct
19 Correct 10 ms 1792 KB Output is correct
20 Correct 10 ms 1536 KB Output is correct
21 Correct 10 ms 1792 KB Output is correct
22 Correct 10 ms 1536 KB Output is correct
23 Correct 10 ms 1792 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 10 ms 1536 KB Output is correct
26 Correct 10 ms 1792 KB Output is correct
27 Correct 10 ms 1536 KB Output is correct
28 Correct 10 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 11868 KB Output is correct
2 Correct 55 ms 12776 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Correct 41 ms 11776 KB Output is correct
5 Correct 60 ms 14372 KB Output is correct
6 Correct 59 ms 14344 KB Output is correct
7 Correct 49 ms 13380 KB Output is correct
8 Correct 49 ms 13428 KB Output is correct
9 Correct 57 ms 14328 KB Output is correct
10 Correct 61 ms 14328 KB Output is correct
11 Correct 59 ms 14332 KB Output is correct
12 Correct 62 ms 14328 KB Output is correct
13 Correct 57 ms 14284 KB Output is correct
14 Correct 59 ms 14336 KB Output is correct
15 Correct 56 ms 14332 KB Output is correct
16 Correct 57 ms 14320 KB Output is correct
17 Correct 57 ms 14036 KB Output is correct
18 Correct 56 ms 14080 KB Output is correct
19 Correct 59 ms 14076 KB Output is correct
20 Correct 59 ms 14064 KB Output is correct
21 Correct 60 ms 14060 KB Output is correct
22 Correct 54 ms 14052 KB Output is correct
23 Correct 47 ms 11952 KB Output is correct
24 Correct 47 ms 11952 KB Output is correct
25 Correct 48 ms 12356 KB Output is correct
26 Correct 49 ms 12352 KB Output is correct
27 Correct 54 ms 12884 KB Output is correct
28 Correct 54 ms 12880 KB Output is correct
29 Correct 56 ms 13252 KB Output is correct
30 Correct 55 ms 13244 KB Output is correct
31 Correct 48 ms 11872 KB Output is correct
32 Correct 47 ms 11960 KB Output is correct
33 Correct 52 ms 12344 KB Output is correct
34 Correct 49 ms 12340 KB Output is correct
35 Correct 53 ms 12964 KB Output is correct
36 Correct 52 ms 12956 KB Output is correct
37 Correct 54 ms 12764 KB Output is correct
38 Correct 56 ms 12892 KB Output is correct
39 Correct 55 ms 12920 KB Output is correct
40 Correct 53 ms 12952 KB Output is correct
41 Correct 54 ms 13412 KB Output is correct
42 Correct 55 ms 13776 KB Output is correct
43 Correct 56 ms 13396 KB Output is correct
44 Correct 55 ms 13560 KB Output is correct
45 Correct 55 ms 13548 KB Output is correct
46 Correct 56 ms 13676 KB Output is correct
47 Correct 51 ms 12628 KB Output is correct
48 Correct 55 ms 12628 KB Output is correct
49 Correct 51 ms 12492 KB Output is correct
50 Correct 55 ms 12888 KB Output is correct
51 Correct 48 ms 12364 KB Output is correct
52 Correct 49 ms 12124 KB Output is correct
53 Correct 48 ms 12372 KB Output is correct
54 Correct 48 ms 12124 KB Output is correct
55 Correct 48 ms 12116 KB Output is correct
56 Correct 49 ms 12364 KB Output is correct
57 Correct 49 ms 11860 KB Output is correct
58 Correct 49 ms 11876 KB Output is correct
59 Correct 54 ms 12380 KB Output is correct
60 Correct 49 ms 12368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 11856 KB Output is correct
2 Correct 51 ms 12660 KB Output is correct
3 Correct 10 ms 1792 KB Output is correct
4 Correct 41 ms 11784 KB Output is correct
5 Correct 57 ms 14336 KB Output is correct
6 Correct 56 ms 14320 KB Output is correct
7 Correct 50 ms 13396 KB Output is correct
8 Correct 50 ms 13760 KB Output is correct
9 Correct 57 ms 14328 KB Output is correct
10 Correct 57 ms 14304 KB Output is correct
11 Correct 59 ms 14332 KB Output is correct
12 Correct 61 ms 14312 KB Output is correct
13 Correct 56 ms 14592 KB Output is correct
14 Correct 56 ms 14320 KB Output is correct
15 Correct 57 ms 14332 KB Output is correct
16 Correct 59 ms 14452 KB Output is correct
17 Correct 59 ms 14064 KB Output is correct
18 Correct 56 ms 14072 KB Output is correct
19 Correct 56 ms 14052 KB Output is correct
20 Correct 63 ms 14048 KB Output is correct
21 Correct 56 ms 14052 KB Output is correct
22 Correct 55 ms 14072 KB Output is correct
23 Correct 46 ms 11952 KB Output is correct
24 Correct 47 ms 11988 KB Output is correct
25 Correct 49 ms 12496 KB Output is correct
26 Correct 47 ms 12484 KB Output is correct
27 Correct 53 ms 12892 KB Output is correct
28 Correct 54 ms 12888 KB Output is correct
29 Correct 55 ms 13012 KB Output is correct
30 Correct 57 ms 13124 KB Output is correct
31 Correct 47 ms 11960 KB Output is correct
32 Correct 46 ms 11964 KB Output is correct
33 Correct 49 ms 12468 KB Output is correct
34 Correct 48 ms 12476 KB Output is correct
35 Correct 53 ms 12956 KB Output is correct
36 Correct 54 ms 12952 KB Output is correct
37 Correct 56 ms 12968 KB Output is correct
38 Correct 53 ms 12940 KB Output is correct
39 Correct 53 ms 12964 KB Output is correct
40 Correct 52 ms 12964 KB Output is correct
41 Correct 55 ms 13420 KB Output is correct
42 Correct 60 ms 13552 KB Output is correct
43 Correct 54 ms 13420 KB Output is correct
44 Correct 54 ms 13540 KB Output is correct
45 Correct 55 ms 13548 KB Output is correct
46 Correct 55 ms 13552 KB Output is correct
47 Correct 51 ms 12892 KB Output is correct
48 Correct 53 ms 12620 KB Output is correct
49 Correct 52 ms 12628 KB Output is correct
50 Correct 52 ms 12748 KB Output is correct
51 Correct 50 ms 12116 KB Output is correct
52 Correct 49 ms 11996 KB Output is correct
53 Correct 48 ms 11996 KB Output is correct
54 Correct 47 ms 12368 KB Output is correct
55 Correct 49 ms 12372 KB Output is correct
56 Correct 50 ms 12220 KB Output is correct
57 Correct 48 ms 11872 KB Output is correct
58 Correct 49 ms 12120 KB Output is correct
59 Correct 48 ms 12116 KB Output is correct
60 Correct 49 ms 12080 KB Output is correct