提交记录 12892


用户 题目 状态 得分 用时 内存 语言 代码长度
Sunward 2002. 【NOIP2018】旅行(加强版) Runtime Error 40 1 s 20272 KB C++ 1.67 KB
提交时间 评测时间
2020-06-24 18:01:43 2020-08-01 03:00:51
#include<bits/stdc++.h>
using namespace std;
int m,n,a1[5001],a2[5001],a3,ans1,d[5001][5001],d1[5001],ans[5001],e[10001],e1[10001],e2[5001],u,v,e5,e6,ans2[5001];
bool b[5001],ok,ok1;
void abc(int c)
{
	++ans1;
	if(ans1>n)return;
	ans[ans1]=c;
	for(int i=1;i<=m;++i)
	{
		if(a1[i]==c&&(b[a2[i]])==0)
		{
			d[c][++d1[c]]=a2[i];
		}
		else if(a2[i]==c&&(b[a1[i]])==0)
		{
			d[c][++d1[c]]=a1[i];
		}
	}
	b[c]=1;
	sort(d[c],d[c]+d1[c]+1);
	for(int i=1;i<=d1[c];++i)
	{
		abc(d[c][i]);
	}
}
void abc1(int c)
{
	if(b[c])return;
	b[c]=1;
	int e3=e2[c];
	d1[c]=0;
	while(e3)
	{
		if(e3==e5||b[e[e3]]||e3==e6)
		{
			e3=e1[e3];
			continue;
		}
		d[c][++d1[c]]=e[e3];
		e3=e1[e3];
	}
	sort(d[c]+1,d[c]+d1[c]+1);
	for(int i=1;i<=d1[c];i++)
	{
		if(ok==0)
		{
			if(d[c][i]>ans[++ans1])
			{
				ok1=1;
				return;
			}
			if(d[c][i]<ans[ans1])
			{
				ok=1;
				ans[ans1]=d[c][i];
			}
		}
		else ans[++ans1]=d[c][i];
		abc1(d[c][i]);
		if(ok1)return;
	}
}
int main()
{
	//freopen("travel.in","r",stdin);
	//freopen("travel.out","w",stdout);
	scanf("%d%d",&n,&m);
	if(m==n-1)
	{
		for(int i=1;i<=m;++i)
		{
			scanf("%d%d",&a1[i],&a2[i]);
		}
		abc(1);
		for(int i=1;i<=n;i++)printf("%d ",ans[i]);
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		e[(i<<1)-1]=v;
		e1[(i<<1)-1]=e2[u];
		e2[u]=(i<<1)-1;
		e[i<<1]=u;
		e1[i<<1]=e2[v];
		e2[v]=i<<1;
	}
	memset(ans,0x3f,sizeof(ans));
	memset(ans2,0x3f,sizeof(ans2));
	ans[1]=1;
	ans2[1]=1;
	for(int j=1;j<=m;j++)
	{
		e5=j<<1;
		e6=e5-1;
		ans1=1;
		ok=0;
		ok1=0;
		memset(b,0,sizeof(b));
		abc1(1);
		if(ok&&ans1==n)for(int i=1;i<=n;i++)ans2[i]=ans[i];
		else for(int i=1;i<=n;i++)ans[i]=ans2[i];
	}
	for(int i=1;i<=n;i++)printf("%d ",ans2[i]);
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #138.7 us72 KBAcceptedScore: 5

Testcase #251.95 us120 KBAcceptedScore: 5

Testcase #385.93 us296 KBAcceptedScore: 5

Testcase #481.87 us340 KBAcceptedScore: 5

Testcase #513.12 ms19 MB + 816 KBAcceptedScore: 5

Testcase #613.113 ms19 MB + 800 KBAcceptedScore: 5

Testcase #7715.66 us108 KBRuntime ErrorScore: 0

Testcase #81.496 ms108 KBRuntime ErrorScore: 0

Testcase #93.431 ms108 KBRuntime ErrorScore: 0

Testcase #104.359 ms108 KBRuntime ErrorScore: 0

Testcase #11781.33 us108 KBRuntime ErrorScore: 0

Testcase #125.867 ms108 KBRuntime ErrorScore: 0

Testcase #1317.35 ms13 MB + 656 KBAcceptedScore: 5

Testcase #1413.805 ms16 MB + 172 KBAcceptedScore: 5

Testcase #155.457 ms904 KBRuntime ErrorScore: 0

Testcase #161 s904 KBTime Limit ExceededScore: 0

Testcase #1731.697 ms3 MB + 956 KBRuntime ErrorScore: 0

Testcase #1831.321 ms3 MB + 956 KBRuntime ErrorScore: 0

Testcase #191 s3 MB + 956 KBTime Limit ExceededScore: 0

Testcase #2031.159 ms3 MB + 956 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2024-04-20 05:34:42 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用