제출 #288913

#제출 시각아이디문제언어결과실행 시간메모리
288913mohammedehab2002길고양이 (JOI20_stray)C++17
91 / 100
66 ms17232 KiB
#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)
		p.push_back(b);
		return l=b;
	}
	if (!y[0] && !y[1])
	{
		p.clear();
		return -1;
	}
	if (p.size()==6)
	{
		for (int i=0;i<6;i++)
		{
			bool eq=1;
			for (int j=0;j<6;j++)
			eq&=(p[(i+j)%6]==seq[j]);
			if (eq)
			{
				p.clear();
				return -1;
			}
		}
	}
	if (y[0]+y[1]==1)
	{
		p.push_back(y[1]);
		return l=y[1];
	}
	p.clear();
	if (!y[l])
	return -1;
	l^=1;
	return l;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...