提交记录 47756


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec 2002. 【NOIP2018】旅行(加强版) Accepted 100 172.095 ms 87496 KB C++17 2.12 KB
提交时间 评测时间
2026-09-13 02:23:09 2026-09-13 02:23:18
// 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;
static char ibuf[1 << 25], obuf[1 << 25];
static char *ip = ibuf, *op = obuf;
inline int read() {
	while((unsigned)(*ip - '0') > 9u) ip++;
	register int r = 0;
	while((unsigned)(*ip - '0') <= 9u) r = r * 10 + (*ip++ - '0');
	return r;
}
inline void wt(int x) {
	char t[12]; int k = 0;
	if (!x) t[k++] = '0';
	while (x) { t[k++] = (char)('0' + x % 10); x /= 10; }
	while (k) *op++ = t[--k];
}
inline void wtln(int x) { wt(x); *op++ = '\n'; }
inline void wtsp(int x) { wt(x); *op++ = ' '; }
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() {
	fread(ibuf, 1, sizeof(ibuf) - 1, stdin);
	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]);
	fwrite(obuf, 1, op - obuf, stdout);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1199.19 us1 MB + 1004 KBAcceptedScore: 5

Testcase #2195.21 us1 MB + 1012 KBAcceptedScore: 5

Testcase #3201.25 us1 MB + 1008 KBAcceptedScore: 5

Testcase #4199.94 us1 MB + 1008 KBAcceptedScore: 5

Testcase #5532 us2 MB + 520 KBAcceptedScore: 5

Testcase #6529.01 us2 MB + 488 KBAcceptedScore: 5

Testcase #711.949 ms12 MB + 500 KBAcceptedScore: 5

Testcase #811.756 ms10 MB + 748 KBAcceptedScore: 5

Testcase #9147.634 ms56 MB + 640 KBAcceptedScore: 5

Testcase #10149.643 ms61 MB + 208 KBAcceptedScore: 5

Testcase #11148.298 ms47 MB + 932 KBAcceptedScore: 5

Testcase #12150.728 ms52 MB + 872 KBAcceptedScore: 5

Testcase #13557.02 us2 MB + 584 KBAcceptedScore: 5

Testcase #14546.33 us2 MB + 676 KBAcceptedScore: 5

Testcase #1511.624 ms14 MB + 260 KBAcceptedScore: 5

Testcase #1611.847 ms15 MB + 268 KBAcceptedScore: 5

Testcase #17172.037 ms85 MB + 456 KBAcceptedScore: 5

Testcase #18172.095 ms85 MB + 456 KBAcceptedScore: 5

Testcase #19140.036 ms61 MB + 708 KBAcceptedScore: 5

Testcase #20158.869 ms74 MB + 964 KBAcceptedScore: 5


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