Submission #212394

# Submission time Handle Problem Language Result Execution time Memory
212394 2020-03-22T21:30:27 Z JustasZ Stray Cat (JOI20_stray) C++14
20 / 100
94 ms 16984 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e4 + 100;
const int mod = 1e9 + 7;

namespace {

	int n, m, A, B;
	vector<int>U, V, label;
	vector<pii>adj[maxn];
	
	void solve1() {
		queue<int>Q;
		vector<int>dist(n, mod);
		dist[0] = 0;
		Q.push(0);

		while (sz(Q)) {
			int v = Q.front();
			Q.pop();
			for (pii to : adj[v]) {
				if (dist[to.x] > dist[v] + 1) {
					dist[to.x] = dist[v] + 1;
					Q.push(to.x);
				}
			}
		}

		for (int i = 0; i < m; i++) {
			label[i] = min(dist[V[i]], dist[U[i]]) % 3;
		}
	}

	string s = "010011";
	void dfs(int v, int p, int prev_label) {
		for (pii to : adj[v]) {
			if (to.x != p) {
				if (sz(adj[v]) > 2) {
					int new_label = (s[prev_label] - '0') ^ 1;
					label[to.y] = new_label;
					dfs(to.x, v, new_label);
				} else {
					int new_label = (prev_label + 1) % 6;
					label[to.y] = (s[new_label] - '0');
					dfs(to.x, v, new_label);
				}
			}
		}
	}

	void solve2() {
		dfs(0, 0, 0);
	}

	vector<int> solve(int N, int M, int AA, int BB, vector<int>UU, vector<int>VV) {
		n = N, m = M, A = AA, B = BB;
		U = UU, V = VV;
		label.resize(m);
		for (int i = 0; i < m; i++) {
			adj[U[i]].pb({V[i], i});
			adj[V[i]].pb({U[i], i});
		}
		if (A >= 3) {
			solve1();
		} else {
			solve2();
		}
		return label;
	}

}  // namespace

vector<int>Mark(int N, int M, int A, int B, vector<int>U, vector<int>V) {
	return solve(N, M, A, B, U, V);
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e4 + 100;
const int mod = 1e9 + 7;

namespace {

	int A, B;
	string cur;
	vector<int>moves;
	bool flag = false;
	int go(vector<int>y) {
		int cnt = y[0] + y[1];
		if (flag) {
			if (cnt == 1) {
				moves.pb((y[0] > 0 ? 0 : 1));
			} else {
				moves.pb(moves.back() ^ 1);
			}
		} else {
			if (cnt == 0) {
				flag = true;
				moves.pb(moves.back());
				return -1;
			}
			if (cnt == 1) {
				
				moves.pb((y[0] > 0 ? 0 : 1));
				goto done;

				if (!sz(moves)) {
					flag = true;
					moves.pb((y[0] > 0 ? 0 : 1));
				} else {
					if (sz(moves) < 4) {
						moves.pb((y[0] > 0 ? 0 : 1));
					} else {
						string t;
						for (int move : moves) {
							t += (move + '0');
						}
						t += (y[0] > 0 ? '0' : '1');
						string s = "110010";
						bool chk = false;
						for (int rot = 0; rot < 6; rot++) {
							if (s.substr(0, 5) == t) {
								chk = true;
							}
							rotate(t.begin(), t.begin() + 1, t.end());
						}
						flag = true;
						if (chk) {
							moves.pb(y[0] > 0 ? 0 : 1);
						} else {
							moves.pb(moves.back());
							return -1;
						}
					}
				}
			} else if (cnt == 2) {
				if (!sz(moves)) {
					if (y[0] && y[1]) {
						moves.pb(0), moves.pb(1);
					} else if (y[0] > 0) {
						moves.pb(0), moves.pb(0);
					} else {
						moves.pb(1), moves.pb(1);
					}
				} else {
					if (!y[0] || !y[1]) {
						flag = true;
						moves.pb(moves.back());
						return -1;
					} else {
						flag = true;
						moves.pb(moves.back() ^ 1);
					}
				}
			} else if (cnt >= 3) {
				flag = true;
				if (!sz(moves)) {
					moves.pb((y[0] == 1 ? 0 : 1));
				} else {
					if (!y[0] || !y[1]) {
						moves.pb(moves.back());
						return -1;
					} else {
						moves.pb(moves.back() ^ 1);
					}
				}
			}
		}

		done: ;
		return moves.back();
	}
}  // namespace

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

int Move(vector<int>y) {
	if (A >= 3) {
		for (int i = 0; i < 3; i++) {
			if (y[i] > 0 && y[(i + 1) % 3] > 0) {
				return i;
			}
		}
		for (int i = 0; i < 3; i++) {
			if (y[i] > 0) {
				return i;
			}
		}
	} else {
		return go(y);
	}
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:129:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 75 ms 15972 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 48 ms 15364 KB Output is correct
4 Correct 81 ms 16936 KB Output is correct
5 Correct 84 ms 16984 KB Output is correct
6 Correct 57 ms 15716 KB Output is correct
7 Correct 61 ms 15804 KB Output is correct
8 Correct 78 ms 16484 KB Output is correct
9 Correct 82 ms 16636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 15972 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 48 ms 15364 KB Output is correct
4 Correct 81 ms 16936 KB Output is correct
5 Correct 84 ms 16984 KB Output is correct
6 Correct 57 ms 15716 KB Output is correct
7 Correct 61 ms 15804 KB Output is correct
8 Correct 78 ms 16484 KB Output is correct
9 Correct 82 ms 16636 KB Output is correct
10 Correct 55 ms 13808 KB Output is correct
11 Correct 65 ms 13820 KB Output is correct
12 Correct 59 ms 13688 KB Output is correct
13 Correct 71 ms 13680 KB Output is correct
14 Correct 58 ms 13944 KB Output is correct
15 Correct 67 ms 14684 KB Output is correct
16 Correct 64 ms 16500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 13560 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 50 ms 13188 KB Output is correct
4 Correct 82 ms 14752 KB Output is correct
5 Correct 79 ms 14836 KB Output is correct
6 Correct 55 ms 13564 KB Output is correct
7 Correct 65 ms 13492 KB Output is correct
8 Correct 68 ms 14324 KB Output is correct
9 Correct 70 ms 14324 KB Output is correct
10 Correct 66 ms 14076 KB Output is correct
11 Correct 77 ms 14076 KB Output is correct
12 Correct 73 ms 13948 KB Output is correct
13 Correct 66 ms 13968 KB Output is correct
14 Correct 72 ms 14332 KB Output is correct
15 Correct 76 ms 14168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 13560 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 50 ms 13188 KB Output is correct
4 Correct 82 ms 14752 KB Output is correct
5 Correct 79 ms 14836 KB Output is correct
6 Correct 55 ms 13564 KB Output is correct
7 Correct 65 ms 13492 KB Output is correct
8 Correct 68 ms 14324 KB Output is correct
9 Correct 70 ms 14324 KB Output is correct
10 Correct 66 ms 14076 KB Output is correct
11 Correct 77 ms 14076 KB Output is correct
12 Correct 73 ms 13948 KB Output is correct
13 Correct 66 ms 13968 KB Output is correct
14 Correct 72 ms 14332 KB Output is correct
15 Correct 76 ms 14168 KB Output is correct
16 Correct 56 ms 11984 KB Output is correct
17 Correct 58 ms 11976 KB Output is correct
18 Correct 59 ms 12028 KB Output is correct
19 Correct 54 ms 12136 KB Output is correct
20 Correct 69 ms 12532 KB Output is correct
21 Correct 62 ms 12492 KB Output is correct
22 Correct 75 ms 14344 KB Output is correct
23 Correct 67 ms 11980 KB Output is correct
24 Correct 53 ms 12128 KB Output is correct
# 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 1536 KB Output is correct
4 Correct 11 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 11 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 11 ms 1792 KB Output is correct
11 Correct 10 ms 1792 KB Output is correct
12 Correct 10 ms 1744 KB Output is correct
13 Correct 10 ms 1792 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 1792 KB Output is correct
17 Correct 11 ms 1536 KB Output is correct
18 Correct 11 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 11 ms 1792 KB Output is correct
23 Correct 10 ms 1548 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 11 ms 1792 KB Output is correct
26 Correct 10 ms 1536 KB Output is correct
27 Correct 11 ms 1792 KB Output is correct
28 Correct 11 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 11744 KB Output is correct
2 Correct 66 ms 13004 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 48 ms 11404 KB Output is correct
5 Correct 73 ms 14412 KB Output is correct
6 Correct 74 ms 14416 KB Output is correct
7 Correct 56 ms 13468 KB Output is correct
8 Correct 55 ms 13548 KB Output is correct
9 Correct 72 ms 14484 KB Output is correct
10 Correct 66 ms 14452 KB Output is correct
11 Correct 73 ms 14612 KB Output is correct
12 Correct 80 ms 14420 KB Output is correct
13 Correct 81 ms 14452 KB Output is correct
14 Correct 94 ms 14540 KB Output is correct
15 Correct 76 ms 14440 KB Output is correct
16 Correct 93 ms 14344 KB Output is correct
17 Correct 76 ms 14100 KB Output is correct
18 Incorrect 67 ms 14088 KB Wrong Answer [6]
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 11780 KB Output is correct
2 Correct 59 ms 12924 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 54 ms 11752 KB Output is correct
5 Correct 68 ms 14324 KB Output is correct
6 Correct 68 ms 14452 KB Output is correct
7 Correct 56 ms 13448 KB Output is correct
8 Incorrect 55 ms 13524 KB Wrong Answer [6]
9 Halted 0 ms 0 KB -