Submission #220217

# Submission time Handle Problem Language Result Execution time Memory
220217 2020-04-07T11:02:39 Z atoiz Stray Cat (JOI20_stray) C++14
85 / 100
73 ms 16980 KB
#include "Anthony.h"
#include <vector>

using namespace std;

namespace Anthony_7 {
	int N, M;
	vector<int> U, V, X;
	vector<vector<int>> adj;

	void dfs(int u, int id, int path_order = -1)
	{
		if (adj[u].size() == 1) return;
		if (adj[u].size() == 2) {
			int nxt = id ^ adj[u][0] ^ adj[u][1];

			if (!~path_order) path_order = X[id];
			path_order = (path_order + 1) % 6;
			X[nxt] = (path_order == 1 || path_order == 4 || path_order == 5);
			return dfs(U[nxt] ^ V[nxt] ^ u, nxt, path_order);
		}

		int x = X[id] ^ 1;
		for (int nxt : adj[u]) if (nxt != id) {
			X[nxt] = x;
			dfs(U[nxt] ^ V[nxt] ^ u, nxt);
		}
	}

	vector<int> mark(int _N, int _M, int A, int B, vector<int> _U, vector<int> _V)
	{
		N = _N, M = _M, U = move(_U), V = move(_V);
		X.resize(M);
		adj.assign(N, vector<int>(0));
		for (int i = 0; i < M; ++i) {
			adj[U[i]].push_back(i);
			adj[V[i]].push_back(i);
		}
		for (int id : adj[0]) {
			X[id] = 0;
			dfs(U[id] ^ V[id], id);
		}
		return X;
	}
}

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V)
{ 
	return Anthony_7::mark(N, M, A, B, U, V);
}
#include "Catherine.h"
#include <vector>
#include <cassert>
#include <numeric>
#include <iostream>

using namespace std;

namespace Catherine_7 {
	bool confused = true;
	int last_col = -1;
	vector<int> prev_cols;

	void init(int _A, int _B)
	{
		confused = true;
		last_col = -1;
		prev_cols.clear();
	}

	int move(vector<int> Y)
	{
		int deg = accumulate(Y.begin(), Y.end(), int(last_col != -1));

		if (deg != 2) {
			if (~last_col) ++Y[last_col];
			confused = false;
			for (int i = 0; i < (int) Y.size(); ++i) {
				if (Y[i] == 1) {
					if (i == last_col) return -1;
					return last_col = i;
				}
			}
			assert(0);
		}

		if (not confused) { // wait up
			assert(~last_col);
			for (int i = 0; i < (int) Y.size(); ++i) {
				if (Y[i] == 1) {
					return last_col = i;
				}
			}
			assert(0);
		}

		for (int i = 0; i < (int) Y.size(); ++i) {
			for (int j = 0; j < Y[i]; ++j) {
				prev_cols.push_back(i);
			}
		}

		cerr << "prev ";
		for (int x : prev_cols) cerr << x << ' ';
		cerr << endl;

		for (int i = 0; i < (int) prev_cols.size() - 1; ++i) if (prev_cols[i] == prev_cols[i + 1]) {
			if (i - 2 >= 0) {
				confused = false;
				if (prev_cols[i - 2] == 0) return last_col = prev_cols[prev_cols.size() - 2], -1;
				else return last_col = prev_cols.back();
			}
			if (i + 3 < (int) prev_cols.size()) {
				confused = false;
				if (prev_cols[i + 3] == 1) return last_col = prev_cols[prev_cols.size() - 2], -1;
				else return last_col = prev_cols.back();
			}
		}
		assert((int) prev_cols.size() < 5);

		return last_col = prev_cols.back();
	}
}

void Init(int A, int B)
{
	Catherine_7::init(A, B);
}

int Move(vector<int> Y)
{
	return Catherine_7::move(Y);
}
# Verdict Execution time Memory Grader output
1 Correct 67 ms 16268 KB Output is correct
2 Correct 9 ms 1028 KB Output is correct
3 Correct 46 ms 15224 KB Output is correct
4 Correct 68 ms 16980 KB Output is correct
5 Correct 68 ms 16952 KB Output is correct
6 Correct 54 ms 16064 KB Output is correct
7 Incorrect 53 ms 16064 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 16268 KB Output is correct
2 Correct 9 ms 1028 KB Output is correct
3 Correct 46 ms 15224 KB Output is correct
4 Correct 68 ms 16980 KB Output is correct
5 Correct 68 ms 16952 KB Output is correct
6 Correct 54 ms 16064 KB Output is correct
7 Incorrect 53 ms 16064 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 13596 KB Output is correct
2 Correct 10 ms 648 KB Output is correct
3 Correct 44 ms 13024 KB Output is correct
4 Correct 65 ms 14660 KB Output is correct
5 Correct 64 ms 14664 KB Output is correct
6 Correct 52 ms 13288 KB Output is correct
7 Incorrect 50 ms 13408 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 13596 KB Output is correct
2 Correct 10 ms 648 KB Output is correct
3 Correct 44 ms 13024 KB Output is correct
4 Correct 65 ms 14660 KB Output is correct
5 Correct 64 ms 14664 KB Output is correct
6 Correct 52 ms 13288 KB Output is correct
7 Incorrect 50 ms 13408 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1132 KB Output is correct
2 Correct 9 ms 776 KB Output is correct
3 Correct 10 ms 1296 KB Output is correct
4 Correct 11 ms 1040 KB Output is correct
5 Correct 10 ms 1256 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1168 KB Output is correct
8 Correct 10 ms 1132 KB Output is correct
9 Correct 10 ms 1144 KB Output is correct
10 Correct 10 ms 1112 KB Output is correct
11 Correct 10 ms 1272 KB Output is correct
12 Correct 10 ms 1140 KB Output is correct
13 Correct 10 ms 1136 KB Output is correct
14 Correct 10 ms 1040 KB Output is correct
15 Correct 10 ms 1132 KB Output is correct
16 Correct 10 ms 1260 KB Output is correct
17 Correct 10 ms 1132 KB Output is correct
18 Correct 10 ms 1132 KB Output is correct
19 Correct 10 ms 1136 KB Output is correct
20 Correct 10 ms 1132 KB Output is correct
21 Correct 10 ms 1132 KB Output is correct
22 Correct 10 ms 1120 KB Output is correct
23 Correct 10 ms 1132 KB Output is correct
24 Correct 10 ms 1144 KB Output is correct
25 Correct 11 ms 1136 KB Output is correct
26 Correct 10 ms 1136 KB Output is correct
27 Correct 10 ms 1120 KB Output is correct
28 Correct 10 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 11812 KB Output is correct
2 Correct 57 ms 12688 KB Output is correct
3 Correct 9 ms 776 KB Output is correct
4 Correct 45 ms 11784 KB Output is correct
5 Correct 61 ms 13268 KB Output is correct
6 Correct 63 ms 13140 KB Output is correct
7 Correct 55 ms 12240 KB Output is correct
8 Correct 52 ms 12248 KB Output is correct
9 Correct 62 ms 13244 KB Output is correct
10 Correct 63 ms 13144 KB Output is correct
11 Correct 61 ms 13120 KB Output is correct
12 Correct 63 ms 13276 KB Output is correct
13 Correct 61 ms 13244 KB Output is correct
14 Correct 62 ms 13256 KB Output is correct
15 Correct 62 ms 13380 KB Output is correct
16 Correct 62 ms 13140 KB Output is correct
17 Correct 61 ms 12884 KB Output is correct
18 Correct 60 ms 12756 KB Output is correct
19 Correct 57 ms 12860 KB Output is correct
20 Correct 59 ms 12884 KB Output is correct
21 Correct 65 ms 12892 KB Output is correct
22 Correct 60 ms 12984 KB Output is correct
23 Correct 47 ms 12084 KB Output is correct
24 Correct 50 ms 12080 KB Output is correct
25 Correct 50 ms 12116 KB Output is correct
26 Correct 51 ms 12188 KB Output is correct
27 Correct 55 ms 12824 KB Output is correct
28 Correct 57 ms 12812 KB Output is correct
29 Correct 55 ms 12824 KB Output is correct
30 Correct 62 ms 12784 KB Output is correct
31 Correct 49 ms 11988 KB Output is correct
32 Correct 53 ms 12060 KB Output is correct
33 Correct 49 ms 12200 KB Output is correct
34 Correct 54 ms 12196 KB Output is correct
35 Correct 56 ms 12492 KB Output is correct
36 Correct 55 ms 12696 KB Output is correct
37 Correct 56 ms 12624 KB Output is correct
38 Correct 55 ms 12492 KB Output is correct
39 Correct 55 ms 12672 KB Output is correct
40 Correct 54 ms 12704 KB Output is correct
41 Correct 59 ms 12756 KB Output is correct
42 Correct 72 ms 13012 KB Output is correct
43 Correct 55 ms 12984 KB Output is correct
44 Correct 73 ms 12884 KB Output is correct
45 Correct 60 ms 13132 KB Output is correct
46 Correct 71 ms 13104 KB Output is correct
47 Correct 55 ms 12596 KB Output is correct
48 Correct 55 ms 12472 KB Output is correct
49 Correct 53 ms 12372 KB Output is correct
50 Correct 55 ms 12624 KB Output is correct
51 Correct 50 ms 12244 KB Output is correct
52 Correct 50 ms 12232 KB Output is correct
53 Correct 49 ms 12372 KB Output is correct
54 Correct 55 ms 12608 KB Output is correct
55 Correct 50 ms 12336 KB Output is correct
56 Correct 50 ms 12368 KB Output is correct
57 Correct 51 ms 12364 KB Output is correct
58 Correct 52 ms 12364 KB Output is correct
59 Correct 50 ms 12116 KB Output is correct
60 Correct 52 ms 12128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 11732 KB Output is correct
2 Correct 53 ms 12436 KB Output is correct
3 Correct 8 ms 904 KB Output is correct
4 Correct 43 ms 11780 KB Output is correct
5 Correct 59 ms 13136 KB Output is correct
6 Correct 62 ms 13020 KB Output is correct
7 Correct 54 ms 12404 KB Output is correct
8 Correct 50 ms 12268 KB Output is correct
9 Correct 63 ms 13140 KB Output is correct
10 Correct 64 ms 13140 KB Output is correct
11 Correct 60 ms 13256 KB Output is correct
12 Correct 62 ms 13132 KB Output is correct
13 Correct 63 ms 13140 KB Output is correct
14 Correct 62 ms 13264 KB Output is correct
15 Correct 71 ms 13132 KB Output is correct
16 Correct 61 ms 13240 KB Output is correct
17 Correct 59 ms 12752 KB Output is correct
18 Correct 61 ms 12756 KB Output is correct
19 Correct 60 ms 12996 KB Output is correct
20 Correct 59 ms 12748 KB Output is correct
21 Correct 59 ms 12880 KB Output is correct
22 Correct 57 ms 12884 KB Output is correct
23 Correct 50 ms 12076 KB Output is correct
24 Correct 48 ms 12024 KB Output is correct
25 Correct 50 ms 12220 KB Output is correct
26 Correct 52 ms 12108 KB Output is correct
27 Correct 54 ms 12812 KB Output is correct
28 Correct 55 ms 12948 KB Output is correct
29 Correct 64 ms 12792 KB Output is correct
30 Correct 55 ms 12728 KB Output is correct
31 Correct 49 ms 12080 KB Output is correct
32 Correct 50 ms 12076 KB Output is correct
33 Correct 61 ms 12108 KB Output is correct
34 Correct 50 ms 12188 KB Output is correct
35 Correct 56 ms 12608 KB Output is correct
36 Correct 55 ms 12684 KB Output is correct
37 Correct 64 ms 12700 KB Output is correct
38 Correct 55 ms 12668 KB Output is correct
39 Correct 56 ms 12684 KB Output is correct
40 Correct 56 ms 12688 KB Output is correct
41 Correct 56 ms 13012 KB Output is correct
42 Correct 59 ms 12880 KB Output is correct
43 Correct 56 ms 12880 KB Output is correct
44 Correct 57 ms 12876 KB Output is correct
45 Correct 59 ms 13008 KB Output is correct
46 Correct 57 ms 12884 KB Output is correct
47 Correct 56 ms 12492 KB Output is correct
48 Correct 54 ms 12608 KB Output is correct
49 Correct 53 ms 12612 KB Output is correct
50 Correct 55 ms 12736 KB Output is correct
51 Correct 51 ms 12372 KB Output is correct
52 Correct 48 ms 12360 KB Output is correct
53 Correct 50 ms 12364 KB Output is correct
54 Correct 53 ms 12244 KB Output is correct
55 Correct 50 ms 12364 KB Output is correct
56 Correct 50 ms 12360 KB Output is correct
57 Correct 54 ms 12360 KB Output is correct
58 Correct 51 ms 12112 KB Output is correct
59 Correct 51 ms 12372 KB Output is correct
60 Correct 50 ms 12368 KB Output is correct