Submission #260580

# Submission time Handle Problem Language Result Execution time Memory
260580 2020-08-10T14:29:22 Z Saboon Stray Cat (JOI20_stray) C++14
15 / 100
71 ms 17300 KB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 20'000 + 10;

int h[maxn], c[maxn];
vector<int> g[maxn];
int Q[maxn], tail, head;

int seq[] = {1, 1, 0, 0, 1, 0};
int col[maxn];

void dfs(int v, int idx = 0, int par = -1){
	for (int i = 0; i < g[v].size(); i++){
		if (g[v][i] == par){
			g[v].erase(g[v].begin()+i);
			break;
		}
	}
	if (g[v].empty())
		return;
	if (g[v].size() == 1){
		col[g[v][0]] = seq[idx];
		dfs(g[v][0], (idx+1)%6, v);
		return;
	}
	for (auto u : g[v]){
		col[u] = 1-col[v];
		dfs(u, 0, v);
	}
}

void bfs(int v){
	memset(h, -1, sizeof h);
	Q[head++] = v;
	h[v] = 0;
	while (tail < head){
		v = Q[tail++];
		for (auto u : g[v])
			if (h[u] == -1)
				h[u] = h[v]+1, Q[head++] = u;
	}
}

vector<int> Mark(int n, int m, int A, int B, vector<int> U, vector<int> V) {
	vector<int> X(m);
	for (int i = 0; i < m; i++){
		g[U[i]].push_back(V[i]);
		g[V[i]].push_back(U[i]);
	}
	bfs(0);
	if (A >= 3){
		for (int i = 0; i < m; i++){
			int v = V[i], u = U[i];
			if (h[v] == h[u])
				X[i] = h[v]%3;
			else
				X[i] = (max(h[v],h[u])+2)%3;
		}
		return X;
	}
	dfs(0);
	for (int i = 0; i < m; i++){
		int v = V[i], u = U[i];
		if (h[v] > h[u])
			X[i] = col[v];
		else
			X[i] = col[u];
	}
	return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

int A, B, last = -1, sure = 0;
string s[] = {"111100", "021001", "110010", "200101", "111011", "110110"};
string now;
bool first;

void Init(int a, int b) {
	A = a, B = b;
	last = -1, sure = 0;
	now.clear();
	first = true;
}


int Move(vector<int> y) {
	if (A >= 3){
		int a = -1, b = -1;
		for (int j = 0; j < A; ++j) {
			if (y[j] != 0){
				if (a == -1)
					a = j;
				else
					b = j;
			}
		}
		if (b == -1)
			return a;
		if (a+1 == b)
			return a;
		return b;
	}
	if (sure){
		if (last != -1)
			y[last] ++;
		if (y[0] > 1)
			return last = 0;
		if (y[1] > 1)
			return last = 1;
		return last = (1-last);
	}
	if (y[0] + y[1] == 0){
		sure = 1;
		return -1;
	}
	if (last == -1 and y[0] + y[1] == 1){
		sure = 1;
		return last = (y[1] == 1);
	}
	if (y[0] == 1 and y[1] + (last == 1) > 1){
		sure = 1;
		return last = 0;
	}
	if (y[1] == 1 and y[0] + (last == 0) > 1){
		sure = 1;
		return last = 1;
	}
	if (first){
		now += (char)(y[0]+'0');
		now += (char)(y[1]+'0');
		now += (char)((y[1]>0)+'0');
		first = false;
		return last = (y[1] > 0);
	}
	now += (char)((y[1]==1)+'0');
	if (now.size() == 6){
		bool found = 0;
		for (int j = 0; j < 6; j++)
			if (now == s[j])
				found = 1;
		sure = 1;
		if (found)
			return -1;
		else
			return last = (y[1] == 1);
	}
	return last = (y[1] == 1);
}

Compilation message

Anthony.cpp: In function 'void dfs(int, int, int)':
Anthony.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < g[v].size(); i++){
                  ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 50 ms 16152 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 41 ms 15156 KB Output is correct
4 Correct 64 ms 17300 KB Output is correct
5 Correct 63 ms 17224 KB Output is correct
6 Correct 50 ms 15880 KB Output is correct
7 Correct 54 ms 15824 KB Output is correct
8 Correct 65 ms 16588 KB Output is correct
9 Correct 63 ms 16640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 16152 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 41 ms 15156 KB Output is correct
4 Correct 64 ms 17300 KB Output is correct
5 Correct 63 ms 17224 KB Output is correct
6 Correct 50 ms 15880 KB Output is correct
7 Correct 54 ms 15824 KB Output is correct
8 Correct 65 ms 16588 KB Output is correct
9 Correct 63 ms 16640 KB Output is correct
10 Correct 44 ms 13760 KB Output is correct
11 Correct 45 ms 13924 KB Output is correct
12 Correct 45 ms 13908 KB Output is correct
13 Correct 45 ms 13916 KB Output is correct
14 Correct 47 ms 14316 KB Output is correct
15 Correct 54 ms 14584 KB Output is correct
16 Correct 55 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 13724 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 44 ms 13112 KB Output is correct
4 Correct 71 ms 15128 KB Output is correct
5 Correct 70 ms 15064 KB Output is correct
6 Correct 48 ms 13696 KB Output is correct
7 Correct 53 ms 13696 KB Output is correct
8 Correct 60 ms 14380 KB Output is correct
9 Correct 62 ms 14444 KB Output is correct
10 Correct 55 ms 14216 KB Output is correct
11 Correct 62 ms 14228 KB Output is correct
12 Correct 57 ms 14224 KB Output is correct
13 Correct 51 ms 14236 KB Output is correct
14 Correct 57 ms 14516 KB Output is correct
15 Correct 59 ms 14412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 13724 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 44 ms 13112 KB Output is correct
4 Correct 71 ms 15128 KB Output is correct
5 Correct 70 ms 15064 KB Output is correct
6 Correct 48 ms 13696 KB Output is correct
7 Correct 53 ms 13696 KB Output is correct
8 Correct 60 ms 14380 KB Output is correct
9 Correct 62 ms 14444 KB Output is correct
10 Correct 55 ms 14216 KB Output is correct
11 Correct 62 ms 14228 KB Output is correct
12 Correct 57 ms 14224 KB Output is correct
13 Correct 51 ms 14236 KB Output is correct
14 Correct 57 ms 14516 KB Output is correct
15 Correct 59 ms 14412 KB Output is correct
16 Correct 43 ms 12108 KB Output is correct
17 Correct 44 ms 12200 KB Output is correct
18 Correct 43 ms 12060 KB Output is correct
19 Correct 43 ms 11996 KB Output is correct
20 Correct 52 ms 12664 KB Output is correct
21 Correct 48 ms 12364 KB Output is correct
22 Correct 57 ms 14624 KB Output is correct
23 Correct 44 ms 11980 KB Output is correct
24 Correct 48 ms 12084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1792 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 11936 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 11784 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -