提交记录 47682


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec noip18d. 【NOIP2018】旅行 Accepted 100 696.2 us 2612 KB C++17 1.98 KB
提交时间 评测时间
2026-09-13 01:20:43 2026-09-13 01:20:50
// This code is AI-generated. (AI 生成的代码)
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define IO(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define I(x) freopen(x".in","r",stdin)
#define R(x) freopen(x".ini","r",stdin),freopen(x".in","w",stdout)
using namespace std;
const int N=500010,inf=20020221;
inline int read() {
	register char c=getchar(),d=0;
	while(c>'9'||c<'0')d=c,c=getchar();
	register int r=0;
	while(c>='0'&&c<='9')r=(r<<1)+(r<<3)+c-'0',c=getchar();
	return d=='-'?-r:r;
}
inline void wt(int x) {
	if(x/10)wt(x/10);
	putchar(x%10+'0');
}
inline void wtln(int x) {
	if(x<0)x=-x,putchar('-');
	wt(x),putchar('\n');
}
inline void wtsp(int x) {
	if(x<0)x=-x,putchar('-');
	wt(x),putchar(' ');
}
struct edge {
	int to,nt,id;
	inline void init(int t,int n,int i) {
		to=t,nt=n,id=i;
	}
} e[N<<1];
int h[N],c=1,x,y;
inline void adde(int f,int t,int i) {
	e[++c].init(t,h[f],i),h[f]=c;
	e[++c].init(f,h[t],i),h[t]=c;
}
int n,m;
int ans[N],tot;

int ste[N],stp[N],top;
int cre[N],crp[N],cc,vis[N];
int oce[N],ocp[N],del;
inline bool fndc(int pos,int pi=0) {
	vis[pos]=1;
	for(int i=h[pos],tps; i; i=e[i].nt) {
		tps=e[i].to;
		if(i==pi)continue;
		ste[++top]=i;
		stp[top]=pos;
		if(vis[tps]) {
			while(1) {
				ocp[stp[top]]=oce[e[ste[top]].id]=1;
				if(stp[top--]==tps)break;
			}
			return 1;
		} else if(fndc(tps,i^1))return 1;
		if(ste[top]==i)--top;
	}
	return 0;
}
int tmp[N],cnt;
inline void dfs(int pos,int nex=inf) {
	vis[pos]=1,ans[++tot]=pos;
	int l=cnt,r;
	for(int i=h[pos]; i; i=e[i].nt)if(!vis[e[i].to])tmp[cnt++]=e[i].to;
	r=cnt,sort(tmp+l,tmp+r);
	for(int i=l,j=l+1; i<r; i=j,++j) {
		if(vis[tmp[i]])continue;
		while(j<r&&vis[tmp[j]])++j;
		if(j<r)dfs(tmp[i],tmp[j]);
		else if(del==0&&ocp[pos]&&ocp[tmp[i]]&&tmp[i]>nex)del=1;
		else dfs(tmp[i],nex);
	}
}
int main() {
	IO("travel");
	n=read(),m=read();
	for(int i=1; i<=m; ++i)
		adde(read(),read(),i);
	fndc(1);
	memset(vis,0,sizeof vis);
	dfs(1);
	for(int i=1; i<n; ++i)
		wtsp(ans[i]);
	wtln(ans[n]);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1198.69 us1 MB + 996 KBAcceptedScore: 4

Testcase #2196.08 us1 MB + 996 KBAcceptedScore: 4

Testcase #3193.79 us1 MB + 996 KBAcceptedScore: 4

Testcase #4201.5 us1 MB + 1000 KBAcceptedScore: 4

Testcase #5201.55 us1 MB + 1000 KBAcceptedScore: 4

Testcase #6263.12 us2 MB + 76 KBAcceptedScore: 4

Testcase #7263.79 us2 MB + 80 KBAcceptedScore: 4

Testcase #8262.73 us2 MB + 88 KBAcceptedScore: 4

Testcase #9274.86 us2 MB + 52 KBAcceptedScore: 4

Testcase #10275.04 us2 MB + 44 KBAcceptedScore: 4

Testcase #11696.2 us2 MB + 392 KBAcceptedScore: 4

Testcase #12687.58 us2 MB + 480 KBAcceptedScore: 4

Testcase #13677.03 us2 MB + 500 KBAcceptedScore: 4

Testcase #14688.74 us2 MB + 392 KBAcceptedScore: 4

Testcase #15683.46 us2 MB + 560 KBAcceptedScore: 4

Testcase #16197.07 us1 MB + 1004 KBAcceptedScore: 4

Testcase #17194.85 us1 MB + 1004 KBAcceptedScore: 4

Testcase #18201.13 us1 MB + 1012 KBAcceptedScore: 4

Testcase #19200.84 us1 MB + 1012 KBAcceptedScore: 4

Testcase #20264.61 us2 MB + 120 KBAcceptedScore: 4

Testcase #21263.31 us2 MB + 120 KBAcceptedScore: 4

Testcase #22263.18 us2 MB + 104 KBAcceptedScore: 4

Testcase #23669.71 us2 MB + 564 KBAcceptedScore: 4

Testcase #24672.14 us2 MB + 544 KBAcceptedScore: 4

Testcase #25670.7 us2 MB + 520 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-24 18:05:40 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠