Submission #262627

# Submission time Handle Problem Language Result Execution time Memory
262627 2020-08-13T06:02:58 Z arnold518 Stray Cat (JOI20_stray) C++14
100 / 100
71 ms 17416 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

static const int MAXN = 2e4;

static int N, M, A, B, D[MAXN+10];
static pii E[MAXN+10];
static vector<pii> adj[MAXN+10];
static vector<int> ret;

static int S[10]={1, 1, 0, 1, 0, 0};

void dfs(int now, int bef, int col, int cnt)
{
	int chd=0;
	if(now==bef) chd=adj[now].size();
	else chd=adj[now].size()-1;
	if(chd>=2)
	{
		for(auto nxt : adj[now])
		{
			if(nxt.first==bef) continue;
			ret[nxt.second-1]=1-col;
			dfs(nxt.first, now, 1-col, 1-col);
		}
	}
	else if(chd==1)
	{
		for(auto nxt : adj[now])
		{
			if(nxt.first==bef) continue;
			ret[nxt.second-1]=S[cnt];
			dfs(nxt.first, now, S[cnt], (cnt+1)%6);
		}
	}
}

vector<int> Mark(int _N, int _M, int _A, int _B, vector<int> _U, vector<int> _V)
{
	N=_N; M=_M; A=_A; B=_B;
	for(int i=1; i<=M; i++)
	{
		int u=_U[i-1]+1, v=_V[i-1]+1;
		adj[u].push_back({v, i});
		adj[v].push_back({u, i});
		E[i]={u, v};
	}
	ret.resize(M);

	if(B==0)
	{
		queue<int> Q;
		memset(D, -1, sizeof(D));
		Q.push(1); D[1]=0;
		while(!Q.empty())
		{
			int now=Q.front(); Q.pop();
			for(auto nxt : adj[now])
			{
				if(D[nxt.first]!=-1) continue;
				Q.push(nxt.first);
				D[nxt.first]=D[now]+1;
			}
		}
		for(int i=1; i<=M; i++) ret[i-1]=min(D[E[i].first], D[E[i].second])%3;
		return ret;
	}

	dfs(1, 1, 1, 0);
	return ret;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

static const int MAXN = 2e4;
static int A, B;
static vector<int> V;
string S;
static int cnt, bef;
static bool up;

vector<string> VV = {"11010", "10100", "10011", "00110", "01101"};

void Init(int _A, int _B)
{
	A=_A; B=_B;
	cnt=0; up=false;
}

int Move(vector<int> _V)
{
	V=_V;
	cnt++;

	if(B==0)
	{
		if(V[0]==0 && V[1]==0) return 2;
		if(V[0]==0 && V[2]==0) return 1;
		if(V[2]==0 && V[1]==0) return 0;

		if(V[0]==0) return 1;
		if(V[1]==0) return 2;
		if(V[2]==0) return 0;
	}

	int deg=0;
	deg=V[0]+V[1];
	if(cnt!=1) deg++;

	if(cnt==1)
	{
		if(V[0]==1 && V[1]==0) { up=true; return bef=0; }
		if(V[0]==0 && V[1]==1) { up=true; return bef=1; }
		if(deg>=3)
		{
			up=true;
			if(V[0]==1) { return bef=0; }
			if(V[1]==1) { return bef=1; }
		}
		assert(deg==2);
		if(V[1]==2) { S.push_back('1'); S.push_back('1'); return bef=1; }
		if(V[0]==2) { S.push_back('0'); S.push_back('0'); return bef=0; }
		if(V[0]==1 && V[1]==1) { S.push_back('1'); S.push_back('0'); return bef=0; }
	}
	else
	{
		if(deg>=3)
		{
			up=true;
			if(V[0]==0) { return -1; }
			if(V[1]==0) { return -1; }
			bef=!bef;
			return bef;
		}
		if(deg==1)
		{
			up=true;
			return -1;
		}
		if(up)
		{
			if(V[1]==1) return bef=1;
			if(V[0]==1) return bef=0;
		}
		if(cnt<4)
		{
			if(V[1]==1) { S.push_back('1'); return bef=1; }
			if(V[0]==1) { S.push_back('0'); return bef=0; }
		}
		if(V[1]==1) S.push_back('1');
		else if(V[0]==1) S.push_back('0');

		bool flag=false;
		for(auto it : VV) if(it==S) flag=true;
		up=true;
		if(flag) return -1;
		else
		{
			if(V[1]==1) return bef=1;
			if(V[0]==1) return bef=0;
		}
	}

}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:98:1: warning: control reaches end of non-void function [-Wreturn-type]
   98 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 53 ms 16408 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 40 ms 15752 KB Output is correct
4 Correct 60 ms 17368 KB Output is correct
5 Correct 60 ms 17416 KB Output is correct
6 Correct 49 ms 16080 KB Output is correct
7 Correct 48 ms 16152 KB Output is correct
8 Correct 59 ms 16716 KB Output is correct
9 Correct 57 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 16408 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 40 ms 15752 KB Output is correct
4 Correct 60 ms 17368 KB Output is correct
5 Correct 60 ms 17416 KB Output is correct
6 Correct 49 ms 16080 KB Output is correct
7 Correct 48 ms 16152 KB Output is correct
8 Correct 59 ms 16716 KB Output is correct
9 Correct 57 ms 16724 KB Output is correct
10 Correct 44 ms 14244 KB Output is correct
11 Correct 44 ms 14152 KB Output is correct
12 Correct 44 ms 14400 KB Output is correct
13 Correct 44 ms 14284 KB Output is correct
14 Correct 45 ms 14464 KB Output is correct
15 Correct 51 ms 15040 KB Output is correct
16 Correct 56 ms 16852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 13988 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 38 ms 13612 KB Output is correct
4 Correct 64 ms 15188 KB Output is correct
5 Correct 58 ms 15184 KB Output is correct
6 Correct 47 ms 13964 KB Output is correct
7 Correct 46 ms 13908 KB Output is correct
8 Correct 54 ms 14548 KB Output is correct
9 Correct 61 ms 14772 KB Output is correct
10 Correct 49 ms 14420 KB Output is correct
11 Correct 52 ms 14520 KB Output is correct
12 Correct 57 ms 14352 KB Output is correct
13 Correct 52 ms 14540 KB Output is correct
14 Correct 55 ms 14796 KB Output is correct
15 Correct 56 ms 14580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 13988 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 38 ms 13612 KB Output is correct
4 Correct 64 ms 15188 KB Output is correct
5 Correct 58 ms 15184 KB Output is correct
6 Correct 47 ms 13964 KB Output is correct
7 Correct 46 ms 13908 KB Output is correct
8 Correct 54 ms 14548 KB Output is correct
9 Correct 61 ms 14772 KB Output is correct
10 Correct 49 ms 14420 KB Output is correct
11 Correct 52 ms 14520 KB Output is correct
12 Correct 57 ms 14352 KB Output is correct
13 Correct 52 ms 14540 KB Output is correct
14 Correct 55 ms 14796 KB Output is correct
15 Correct 56 ms 14580 KB Output is correct
16 Correct 41 ms 12460 KB Output is correct
17 Correct 47 ms 12532 KB Output is correct
18 Correct 45 ms 12364 KB Output is correct
19 Correct 51 ms 12492 KB Output is correct
20 Correct 58 ms 13140 KB Output is correct
21 Correct 47 ms 12852 KB Output is correct
22 Correct 58 ms 14676 KB Output is correct
23 Correct 48 ms 12376 KB Output is correct
24 Correct 46 ms 12356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1792 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 2 ms 1792 KB Output is correct
4 Correct 2 ms 1792 KB Output is correct
5 Correct 2 ms 1792 KB Output is correct
6 Correct 3 ms 1792 KB Output is correct
7 Correct 2 ms 1792 KB Output is correct
8 Correct 2 ms 1792 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 2 ms 1792 KB Output is correct
12 Correct 2 ms 1792 KB Output is correct
13 Correct 2 ms 1792 KB Output is correct
14 Correct 2 ms 1792 KB Output is correct
15 Correct 2 ms 1792 KB Output is correct
16 Correct 2 ms 1792 KB Output is correct
17 Correct 2 ms 1792 KB Output is correct
18 Correct 2 ms 1792 KB Output is correct
19 Correct 2 ms 1792 KB Output is correct
20 Correct 2 ms 1792 KB Output is correct
21 Correct 2 ms 1792 KB Output is correct
22 Correct 2 ms 1792 KB Output is correct
23 Correct 2 ms 1792 KB Output is correct
24 Correct 2 ms 1792 KB Output is correct
25 Correct 2 ms 1792 KB Output is correct
26 Correct 2 ms 1792 KB Output is correct
27 Correct 2 ms 1792 KB Output is correct
28 Correct 2 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 12092 KB Output is correct
2 Correct 50 ms 13264 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 39 ms 11932 KB Output is correct
5 Correct 58 ms 14456 KB Output is correct
6 Correct 65 ms 14592 KB Output is correct
7 Correct 47 ms 13420 KB Output is correct
8 Correct 50 ms 13424 KB Output is correct
9 Correct 62 ms 14284 KB Output is correct
10 Correct 66 ms 14564 KB Output is correct
11 Correct 58 ms 14444 KB Output is correct
12 Correct 65 ms 14316 KB Output is correct
13 Correct 60 ms 14436 KB Output is correct
14 Correct 59 ms 14336 KB Output is correct
15 Correct 60 ms 14412 KB Output is correct
16 Correct 71 ms 14292 KB Output is correct
17 Correct 53 ms 14032 KB Output is correct
18 Correct 51 ms 13908 KB Output is correct
19 Correct 51 ms 14036 KB Output is correct
20 Correct 54 ms 13908 KB Output is correct
21 Correct 51 ms 14092 KB Output is correct
22 Correct 56 ms 14068 KB Output is correct
23 Correct 41 ms 11988 KB Output is correct
24 Correct 46 ms 12072 KB Output is correct
25 Correct 44 ms 12364 KB Output is correct
26 Correct 46 ms 12364 KB Output is correct
27 Correct 49 ms 13184 KB Output is correct
28 Correct 59 ms 13180 KB Output is correct
29 Correct 57 ms 13164 KB Output is correct
30 Correct 50 ms 13172 KB Output is correct
31 Correct 41 ms 12228 KB Output is correct
32 Correct 50 ms 12116 KB Output is correct
33 Correct 50 ms 12240 KB Output is correct
34 Correct 48 ms 12268 KB Output is correct
35 Correct 49 ms 13080 KB Output is correct
36 Correct 59 ms 13356 KB Output is correct
37 Correct 49 ms 13240 KB Output is correct
38 Correct 49 ms 13228 KB Output is correct
39 Correct 60 ms 13060 KB Output is correct
40 Correct 59 ms 13232 KB Output is correct
41 Correct 54 ms 13616 KB Output is correct
42 Correct 56 ms 13612 KB Output is correct
43 Correct 55 ms 13644 KB Output is correct
44 Correct 55 ms 13736 KB Output is correct
45 Correct 53 ms 13524 KB Output is correct
46 Correct 56 ms 13724 KB Output is correct
47 Correct 49 ms 12916 KB Output is correct
48 Correct 49 ms 12876 KB Output is correct
49 Correct 47 ms 12628 KB Output is correct
50 Correct 56 ms 12884 KB Output is correct
51 Correct 47 ms 12304 KB Output is correct
52 Correct 48 ms 12296 KB Output is correct
53 Correct 49 ms 12300 KB Output is correct
54 Correct 45 ms 12212 KB Output is correct
55 Correct 46 ms 12372 KB Output is correct
56 Correct 43 ms 12440 KB Output is correct
57 Correct 46 ms 12352 KB Output is correct
58 Correct 46 ms 12336 KB Output is correct
59 Correct 44 ms 12116 KB Output is correct
60 Correct 43 ms 12116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 12092 KB Output is correct
2 Correct 48 ms 13044 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 36 ms 11700 KB Output is correct
5 Correct 56 ms 14448 KB Output is correct
6 Correct 56 ms 14572 KB Output is correct
7 Correct 46 ms 13552 KB Output is correct
8 Correct 47 ms 13552 KB Output is correct
9 Correct 58 ms 14292 KB Output is correct
10 Correct 56 ms 14572 KB Output is correct
11 Correct 55 ms 14316 KB Output is correct
12 Correct 54 ms 14420 KB Output is correct
13 Correct 55 ms 14444 KB Output is correct
14 Correct 55 ms 14476 KB Output is correct
15 Correct 57 ms 14448 KB Output is correct
16 Correct 54 ms 14320 KB Output is correct
17 Correct 55 ms 14052 KB Output is correct
18 Correct 52 ms 14028 KB Output is correct
19 Correct 53 ms 14064 KB Output is correct
20 Correct 54 ms 13908 KB Output is correct
21 Correct 50 ms 13900 KB Output is correct
22 Correct 55 ms 14036 KB Output is correct
23 Correct 44 ms 12100 KB Output is correct
24 Correct 45 ms 12148 KB Output is correct
25 Correct 50 ms 12396 KB Output is correct
26 Correct 46 ms 12392 KB Output is correct
27 Correct 53 ms 13004 KB Output is correct
28 Correct 52 ms 13140 KB Output is correct
29 Correct 60 ms 13168 KB Output is correct
30 Correct 62 ms 13156 KB Output is correct
31 Correct 44 ms 12128 KB Output is correct
32 Correct 44 ms 11988 KB Output is correct
33 Correct 45 ms 12372 KB Output is correct
34 Correct 43 ms 12388 KB Output is correct
35 Correct 51 ms 13104 KB Output is correct
36 Correct 50 ms 13012 KB Output is correct
37 Correct 63 ms 13132 KB Output is correct
38 Correct 52 ms 13012 KB Output is correct
39 Correct 48 ms 13112 KB Output is correct
40 Correct 48 ms 13244 KB Output is correct
41 Correct 54 ms 13720 KB Output is correct
42 Correct 53 ms 13652 KB Output is correct
43 Correct 51 ms 13588 KB Output is correct
44 Correct 53 ms 13524 KB Output is correct
45 Correct 52 ms 13736 KB Output is correct
46 Correct 56 ms 13724 KB Output is correct
47 Correct 63 ms 12876 KB Output is correct
48 Correct 48 ms 12924 KB Output is correct
49 Correct 51 ms 12628 KB Output is correct
50 Correct 53 ms 12912 KB Output is correct
51 Correct 44 ms 12244 KB Output is correct
52 Correct 55 ms 12292 KB Output is correct
53 Correct 43 ms 12292 KB Output is correct
54 Correct 45 ms 12308 KB Output is correct
55 Correct 44 ms 12108 KB Output is correct
56 Correct 49 ms 12108 KB Output is correct
57 Correct 47 ms 12416 KB Output is correct
58 Correct 44 ms 12116 KB Output is correct
59 Correct 43 ms 12348 KB Output is correct
60 Correct 45 ms 12352 KB Output is correct