Submission #216730

# Submission time Handle Problem Language Result Execution time Memory
216730 2020-03-27T23:49:50 Z ainta Stray Cat (JOI20_stray) C++17
85 / 100
74 ms 18136 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_];

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;
  for (i = 0; i < M; i++) {
	  E[U[i]].push_back(V[i]);
	  E[V[i]].push_back(U[i]);
  }
  Dep[0] = 0;
  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]];
  }
  return X;
}
#include "Catherine.h"
#include <vector>


int s, ok, dd;
int L[3];
void Init(int A, int 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 (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:19:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
Catherine.cpp:121:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 54 ms 16480 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 45 ms 15412 KB Output is correct
4 Correct 64 ms 18136 KB Output is correct
5 Incorrect 61 ms 18024 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 16480 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 45 ms 15412 KB Output is correct
4 Correct 64 ms 18136 KB Output is correct
5 Incorrect 61 ms 18024 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 14280 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 47 ms 13320 KB Output is correct
4 Correct 61 ms 15848 KB Output is correct
5 Incorrect 57 ms 15984 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 14280 KB Output is correct
2 Correct 9 ms 1536 KB Output is correct
3 Correct 47 ms 13320 KB Output is correct
4 Correct 61 ms 15848 KB Output is correct
5 Incorrect 57 ms 15984 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 10 ms 1792 KB Output is correct
4 Correct 10 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 11 ms 1792 KB Output is correct
9 Correct 11 ms 1792 KB Output is correct
10 Correct 10 ms 1792 KB Output is correct
11 Correct 10 ms 1792 KB Output is correct
12 Correct 10 ms 1792 KB Output is correct
13 Correct 10 ms 1792 KB Output is correct
14 Correct 10 ms 1792 KB Output is correct
15 Correct 11 ms 1792 KB Output is correct
16 Correct 10 ms 1536 KB Output is correct
17 Correct 10 ms 1536 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 1792 KB Output is correct
21 Correct 10 ms 1792 KB Output is correct
22 Correct 10 ms 1536 KB Output is correct
23 Correct 11 ms 1888 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 10 ms 1792 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
# Verdict Execution time Memory Grader output
1 Correct 47 ms 11952 KB Output is correct
2 Correct 52 ms 12768 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Correct 41 ms 11780 KB Output is correct
5 Correct 71 ms 14348 KB Output is correct
6 Correct 60 ms 14300 KB Output is correct
7 Correct 49 ms 13428 KB Output is correct
8 Correct 50 ms 13388 KB Output is correct
9 Correct 57 ms 14292 KB Output is correct
10 Correct 65 ms 14412 KB Output is correct
11 Correct 71 ms 14276 KB Output is correct
12 Correct 60 ms 14300 KB Output is correct
13 Correct 62 ms 14300 KB Output is correct
14 Correct 62 ms 14336 KB Output is correct
15 Correct 62 ms 14452 KB Output is correct
16 Correct 64 ms 14328 KB Output is correct
17 Correct 60 ms 14064 KB Output is correct
18 Correct 70 ms 14056 KB Output is correct
19 Correct 64 ms 14028 KB Output is correct
20 Correct 60 ms 14044 KB Output is correct
21 Correct 60 ms 14036 KB Output is correct
22 Correct 67 ms 14036 KB Output is correct
23 Correct 54 ms 11808 KB Output is correct
24 Correct 51 ms 11868 KB Output is correct
25 Correct 50 ms 12372 KB Output is correct
26 Correct 51 ms 12164 KB Output is correct
27 Correct 74 ms 13124 KB Output is correct
28 Correct 56 ms 12896 KB Output is correct
29 Correct 56 ms 13140 KB Output is correct
30 Correct 55 ms 13252 KB Output is correct
31 Correct 51 ms 11956 KB Output is correct
32 Correct 50 ms 11948 KB Output is correct
33 Correct 47 ms 12356 KB Output is correct
34 Correct 50 ms 12232 KB Output is correct
35 Correct 54 ms 12884 KB Output is correct
36 Correct 53 ms 12952 KB Output is correct
37 Correct 54 ms 12928 KB Output is correct
38 Correct 52 ms 12956 KB Output is correct
39 Correct 57 ms 12876 KB Output is correct
40 Correct 60 ms 12960 KB Output is correct
41 Correct 55 ms 13416 KB Output is correct
42 Correct 54 ms 13424 KB Output is correct
43 Correct 56 ms 13420 KB Output is correct
44 Correct 65 ms 13864 KB Output is correct
45 Correct 56 ms 13388 KB Output is correct
46 Correct 56 ms 13524 KB Output is correct
47 Correct 50 ms 12628 KB Output is correct
48 Correct 52 ms 13012 KB Output is correct
49 Correct 50 ms 12636 KB Output is correct
50 Correct 59 ms 12984 KB Output is correct
51 Correct 47 ms 11988 KB Output is correct
52 Correct 52 ms 12368 KB Output is correct
53 Correct 48 ms 12356 KB Output is correct
54 Correct 49 ms 12212 KB Output is correct
55 Correct 49 ms 11996 KB Output is correct
56 Correct 52 ms 12248 KB Output is correct
57 Correct 48 ms 12096 KB Output is correct
58 Correct 49 ms 11868 KB Output is correct
59 Correct 49 ms 12348 KB Output is correct
60 Correct 48 ms 12116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 11984 KB Output is correct
2 Correct 51 ms 12620 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 43 ms 11772 KB Output is correct
5 Correct 64 ms 14376 KB Output is correct
6 Correct 59 ms 14324 KB Output is correct
7 Correct 52 ms 13444 KB Output is correct
8 Correct 49 ms 13440 KB Output is correct
9 Correct 66 ms 14412 KB Output is correct
10 Correct 59 ms 14300 KB Output is correct
11 Correct 61 ms 14412 KB Output is correct
12 Correct 65 ms 14296 KB Output is correct
13 Correct 59 ms 14332 KB Output is correct
14 Correct 62 ms 14452 KB Output is correct
15 Correct 57 ms 14328 KB Output is correct
16 Correct 60 ms 14316 KB Output is correct
17 Correct 56 ms 14068 KB Output is correct
18 Correct 62 ms 14036 KB Output is correct
19 Correct 56 ms 14072 KB Output is correct
20 Correct 55 ms 14072 KB Output is correct
21 Correct 61 ms 14080 KB Output is correct
22 Correct 57 ms 14020 KB Output is correct
23 Correct 47 ms 11864 KB Output is correct
24 Correct 47 ms 11924 KB Output is correct
25 Correct 48 ms 12368 KB Output is correct
26 Correct 54 ms 12480 KB Output is correct
27 Correct 53 ms 13128 KB Output is correct
28 Correct 54 ms 12884 KB Output is correct
29 Correct 53 ms 13252 KB Output is correct
30 Correct 54 ms 13136 KB Output is correct
31 Correct 51 ms 11956 KB Output is correct
32 Correct 47 ms 11940 KB Output is correct
33 Correct 51 ms 12320 KB Output is correct
34 Correct 49 ms 12364 KB Output is correct
35 Correct 54 ms 13020 KB Output is correct
36 Correct 54 ms 12892 KB Output is correct
37 Correct 54 ms 12964 KB Output is correct
38 Correct 54 ms 13088 KB Output is correct
39 Correct 60 ms 12952 KB Output is correct
40 Correct 53 ms 12936 KB Output is correct
41 Correct 55 ms 13524 KB Output is correct
42 Correct 55 ms 13424 KB Output is correct
43 Correct 57 ms 13652 KB Output is correct
44 Correct 60 ms 13552 KB Output is correct
45 Correct 55 ms 13548 KB Output is correct
46 Correct 55 ms 13540 KB Output is correct
47 Correct 52 ms 12968 KB Output is correct
48 Correct 53 ms 12860 KB Output is correct
49 Correct 50 ms 12632 KB Output is correct
50 Correct 52 ms 12764 KB Output is correct
51 Correct 48 ms 12240 KB Output is correct
52 Correct 48 ms 11988 KB Output is correct
53 Correct 47 ms 12368 KB Output is correct
54 Correct 49 ms 12120 KB Output is correct
55 Correct 49 ms 12368 KB Output is correct
56 Correct 52 ms 12208 KB Output is correct
57 Correct 49 ms 11860 KB Output is correct
58 Correct 49 ms 11872 KB Output is correct
59 Correct 49 ms 12364 KB Output is correct
60 Correct 54 ms 12236 KB Output is correct