Submission #288915

# Submission time Handle Problem Language Result Execution time Memory
288915 2020-09-02T07:09:25 Z mohammedehab2002 Stray Cat (JOI20_stray) C++17
29 / 100
72 ms 16804 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
	int seq[]={1,0,1,1,0,0},dist[20005];
	vector<pair<int,int> > v[20005];
	vector<int> ans;
}
void dfs(int node,int p,int idx,int gp)
{
	int c=(int)v[node].size()-(p!=-1);
	for (auto u:v[node])
	{
		if (u.first!=p)
		{
			if (c==1)
			{
				ans[u.second]=seq[idx];
				dfs(u.first,node,(idx+1)%6,seq[idx]);
			}
			else
			{
				ans[u.second]=!gp;
				dfs(u.first,node,0,!gp);
			}
		}
	}
}
vector<int> Mark(int n,int m,int A,int B,vector<int> a,vector<int> b)
{
	for (int i=0;i<m;i++)
	{
		v[a[i]].push_back({b[i],i});
		v[b[i]].push_back({a[i],i});
	}
	ans=vector<int>(m,-1);
	if (A==2)
	dfs(0,-1,0,0);
	else
	{
		memset(dist,-1,sizeof(dist));
		queue<int> q;
		q.push(0);
		dist[0]=0;
		while (!q.empty())
		{
			int node=q.front();
			q.pop();
			for (auto u:v[node])
			{
				if (dist[u.first]==-1)
				{
					dist[u.first]=dist[node]+1;
					q.push(u.first);
				}
				if (ans[u.second]==-1)
				ans[u.second]=dist[node]%3;
			}
		}
	}
	return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
	bool f;
	int l,seq[]={1,0,1,1,0,0};
	vector<int> p;
}
void Init(int A, int B){}
int Move(vector<int> y)
{
	if (y.size()>2)
	{
		if ((bool)y[0]+(bool)y[1]+(bool)y[2]==1)
		{
			for (int i=0;i<3;i++)
			{
				if (y[i])
				return i;
			}
		}
		for (int i=0;i<3;i++)
		{
			if (!y[i])
			return (i+1)%3;
		}
	}
	if (!f)
	{
		f=1;
		bool b=(y[0]>y[1]);
		if (!y[b])
		b^=1;
		if (y[0]+y[1]==2)
		{
			if (y[b]==2)
			p.push_back(b);
			else
			p.push_back(!b);
			p.push_back(b);
		}
		return l=b;
	}
	if (!y[0] && !y[1])
	{
		p.clear();
		return -1;
	}
	if (y[0]+y[1]==1)
	{
		p.push_back(y[1]);
		if (p.size()==5)
		{
			for (int i=0;i<6;i++)
			{
				bool eq=1;
				for (int j=0;j<5;j++)
				eq&=(p[j]==seq[(i+j)%6]);
				if (eq)
				{
					p.clear();
					return -1;
				}
			}
		}
		return l=y[1];
	}
	p.clear();
	if (!y[l])
	return -1;
	l^=1;
	return l;
}
# Verdict Execution time Memory Grader output
1 Correct 58 ms 15860 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 44 ms 15096 KB Output is correct
4 Correct 69 ms 16756 KB Output is correct
5 Correct 66 ms 16804 KB Output is correct
6 Correct 51 ms 15544 KB Output is correct
7 Correct 56 ms 15424 KB Output is correct
8 Correct 65 ms 16364 KB Output is correct
9 Correct 72 ms 16364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 15860 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 44 ms 15096 KB Output is correct
4 Correct 69 ms 16756 KB Output is correct
5 Correct 66 ms 16804 KB Output is correct
6 Correct 51 ms 15544 KB Output is correct
7 Correct 56 ms 15424 KB Output is correct
8 Correct 65 ms 16364 KB Output is correct
9 Correct 72 ms 16364 KB Output is correct
10 Correct 46 ms 13792 KB Output is correct
11 Correct 52 ms 13552 KB Output is correct
12 Correct 48 ms 13672 KB Output is correct
13 Correct 45 ms 13800 KB Output is correct
14 Correct 47 ms 13816 KB Output is correct
15 Correct 55 ms 14320 KB Output is correct
16 Correct 58 ms 16292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 13364 KB Output is correct
2 Correct 2 ms 1792 KB Output is correct
3 Correct 39 ms 13036 KB Output is correct
4 Correct 66 ms 14756 KB Output is correct
5 Correct 61 ms 14624 KB Output is correct
6 Correct 46 ms 13360 KB Output is correct
7 Correct 47 ms 13364 KB Output is correct
8 Correct 59 ms 14092 KB Output is correct
9 Correct 56 ms 14056 KB Output is correct
10 Correct 58 ms 13820 KB Output is correct
11 Correct 52 ms 14032 KB Output is correct
12 Correct 53 ms 13920 KB Output is correct
13 Correct 53 ms 13924 KB Output is correct
14 Correct 59 ms 14068 KB Output is correct
15 Correct 56 ms 13948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 13364 KB Output is correct
2 Correct 2 ms 1792 KB Output is correct
3 Correct 39 ms 13036 KB Output is correct
4 Correct 66 ms 14756 KB Output is correct
5 Correct 61 ms 14624 KB Output is correct
6 Correct 46 ms 13360 KB Output is correct
7 Correct 47 ms 13364 KB Output is correct
8 Correct 59 ms 14092 KB Output is correct
9 Correct 56 ms 14056 KB Output is correct
10 Correct 58 ms 13820 KB Output is correct
11 Correct 52 ms 14032 KB Output is correct
12 Correct 53 ms 13920 KB Output is correct
13 Correct 53 ms 13924 KB Output is correct
14 Correct 59 ms 14068 KB Output is correct
15 Correct 56 ms 13948 KB Output is correct
16 Correct 41 ms 11640 KB Output is correct
17 Correct 43 ms 11836 KB Output is correct
18 Correct 44 ms 11884 KB Output is correct
19 Correct 44 ms 11880 KB Output is correct
20 Correct 50 ms 12420 KB Output is correct
21 Correct 47 ms 12268 KB Output is correct
22 Correct 55 ms 14116 KB Output is correct
23 Correct 44 ms 12016 KB Output is correct
24 Correct 47 ms 11896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 2 ms 1792 KB Output is correct
5 Correct 2 ms 1792 KB Output is correct
6 Correct 2 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 1536 KB Output is correct
17 Correct 2 ms 1792 KB Output is correct
18 Correct 2 ms 1536 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 1536 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 1536 KB Output is correct
26 Correct 2 ms 1536 KB Output is correct
27 Correct 2 ms 1556 KB Output is correct
28 Correct 2 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 11476 KB Output is correct
2 Correct 49 ms 12800 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 37 ms 11316 KB Output is correct
5 Correct 58 ms 14068 KB Output is correct
6 Correct 59 ms 14284 KB Output is correct
7 Correct 49 ms 13352 KB Output is correct
8 Correct 46 ms 13180 KB Output is correct
9 Correct 57 ms 14300 KB Output is correct
10 Correct 58 ms 14068 KB Output is correct
11 Correct 58 ms 14292 KB Output is correct
12 Correct 59 ms 14280 KB Output is correct
13 Correct 58 ms 14076 KB Output is correct
14 Correct 60 ms 14288 KB Output is correct
15 Correct 60 ms 14288 KB Output is correct
16 Correct 61 ms 14284 KB Output is correct
17 Correct 57 ms 14008 KB Output is correct
18 Correct 57 ms 13996 KB Output is correct
19 Correct 53 ms 14044 KB Output is correct
20 Correct 54 ms 14048 KB Output is correct
21 Correct 54 ms 13948 KB Output is correct
22 Correct 56 ms 13948 KB Output is correct
23 Correct 43 ms 11388 KB Output is correct
24 Correct 44 ms 11504 KB Output is correct
25 Correct 46 ms 11964 KB Output is correct
26 Correct 45 ms 11892 KB Output is correct
27 Correct 62 ms 12660 KB Output is correct
28 Correct 53 ms 12672 KB Output is correct
29 Correct 51 ms 12896 KB Output is correct
30 Correct 53 ms 12900 KB Output is correct
31 Correct 44 ms 11836 KB Output is correct
32 Correct 43 ms 11516 KB Output is correct
33 Correct 44 ms 11772 KB Output is correct
34 Correct 44 ms 11960 KB Output is correct
35 Incorrect 52 ms 12748 KB Wrong Answer [6]
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 11260 KB Output is correct
2 Correct 49 ms 12428 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 37 ms 11128 KB Output is correct
5 Correct 56 ms 14292 KB Output is correct
6 Correct 57 ms 14304 KB Output is correct
7 Correct 50 ms 13284 KB Output is correct
8 Correct 48 ms 13400 KB Output is correct
9 Correct 59 ms 14292 KB Output is correct
10 Correct 62 ms 14196 KB Output is correct
11 Correct 60 ms 14196 KB Output is correct
12 Correct 58 ms 14068 KB Output is correct
13 Correct 59 ms 14036 KB Output is correct
14 Correct 59 ms 14196 KB Output is correct
15 Correct 59 ms 14296 KB Output is correct
16 Correct 59 ms 14684 KB Output is correct
17 Correct 55 ms 14168 KB Output is correct
18 Correct 57 ms 14168 KB Output is correct
19 Correct 55 ms 14292 KB Output is correct
20 Correct 55 ms 14300 KB Output is correct
21 Correct 55 ms 14168 KB Output is correct
22 Correct 54 ms 14172 KB Output is correct
23 Correct 43 ms 11836 KB Output is correct
24 Correct 41 ms 11720 KB Output is correct
25 Correct 48 ms 12484 KB Output is correct
26 Correct 47 ms 12552 KB Output is correct
27 Correct 54 ms 13260 KB Output is correct
28 Correct 52 ms 13192 KB Output is correct
29 Correct 52 ms 13416 KB Output is correct
30 Correct 55 ms 13288 KB Output is correct
31 Correct 44 ms 11884 KB Output is correct
32 Correct 46 ms 11732 KB Output is correct
33 Correct 53 ms 12364 KB Output is correct
34 Correct 45 ms 12480 KB Output is correct
35 Correct 51 ms 12984 KB Output is correct
36 Correct 54 ms 13012 KB Output is correct
37 Correct 52 ms 13188 KB Output is correct
38 Correct 49 ms 13268 KB Output is correct
39 Correct 52 ms 13140 KB Output is correct
40 Correct 51 ms 13248 KB Output is correct
41 Correct 54 ms 13644 KB Output is correct
42 Correct 53 ms 13524 KB Output is correct
43 Correct 53 ms 13668 KB Output is correct
44 Correct 59 ms 13772 KB Output is correct
45 Correct 61 ms 13668 KB Output is correct
46 Correct 55 ms 13800 KB Output is correct
47 Correct 54 ms 12948 KB Output is correct
48 Correct 51 ms 12948 KB Output is correct
49 Correct 51 ms 12816 KB Output is correct
50 Correct 52 ms 12952 KB Output is correct
51 Correct 46 ms 12252 KB Output is correct
52 Correct 47 ms 12340 KB Output is correct
53 Correct 46 ms 12108 KB Output is correct
54 Correct 47 ms 12320 KB Output is correct
55 Correct 49 ms 12268 KB Output is correct
56 Correct 45 ms 12200 KB Output is correct
57 Correct 50 ms 12364 KB Output is correct
58 Correct 45 ms 12340 KB Output is correct
59 Correct 49 ms 11988 KB Output is correct
60 Correct 46 ms 12120 KB Output is correct