提交记录 7874
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
Panda_hu | noip18d. 【NOIP2018】旅行 | Accepted | 100 | 707.598 ms | 35868 KB | C++ | 1.50 KB |
提交时间 | 评测时间 |
---|---|
2019-01-25 19:16:44 | 2020-08-01 01:09:34 |
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define MAXN 5000
struct node
{
int u,v;
}a[MAXN+5];
int n,m;
int vis[MAXN+5],ans[MAXN+5],seq[MAXN+5],top;
vector<int> G[MAXN+5];
int Gr[MAXN+5][MAXN+5];
void dfs(int x)
{
vis[x]=1;
seq[++top]=x;
for(int i=0;i<G[x].size();i++)
{
int xnt=G[x][i];
if(vis[xnt]||!Gr[x][xnt])continue;
dfs(xnt);
}
}
int main()
{
// freopen("travel.in","r",stdin);
// freopen("travel.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)ans[i]=n+1;
for(int i=1;i<=m;i++)
{
int u,v;
scanf("%d%d",&u,&v);
a[i].u=u,a[i].v=v;
G[u].push_back(v);
G[v].push_back(u);
Gr[u][v]=1;
Gr[v][u]=1;
}
for(int i=1;i<=n;i++)
sort(G[i].begin(),G[i].end());
if(n==m)
for(int i=1;i<=m;i++)
{
top=0;
for(int j=1;j<=n;j++)
vis[j]=0;
Gr[a[i].u][a[i].v]=0;
Gr[a[i].v][a[i].u]=0;
dfs(1);
Gr[a[i].u][a[i].v]=1;
Gr[a[i].v][a[i].u]=1;
if(top<n)continue;
int F=1;
for(int j=1;j<=n;j++)
if(ans[j]>seq[j])break;
else if(ans[j]<seq[j]){F=0;break;}
if(F)
{
for(int j=1;j<=n;j++)
ans[j]=seq[j];
}
}
else
{
dfs(1);
for(int i=1;i<=n;i++)
ans[i]=seq[i];
}
for(int i=1;i<=n;i++)
printf("%d ",ans[i]);
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 60.1 us | 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 67.04 us | 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 60.54 us | 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 115.94 us | 584 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 106.84 us | 584 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 651.62 us | 5 MB + 372 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 658.43 us | 5 MB + 480 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 662.33 us | 5 MB + 544 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 653.89 us | 5 MB + 224 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 652.32 us | 5 MB + 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 3.675 ms | 34 MB + 416 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 3.694 ms | 34 MB + 712 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 3.69 ms | 34 MB + 872 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 3.668 ms | 34 MB + 360 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 3.706 ms | 35 MB + 28 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 61.45 us | 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 60.28 us | 212 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 169.81 us | 588 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 171.32 us | 580 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 11.929 ms | 5 MB + 396 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 11.886 ms | 5 MB + 560 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 12.2 ms | 5 MB + 492 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 707.598 ms | 34 MB + 896 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 705.92 ms | 34 MB + 584 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 703.617 ms | 34 MB + 452 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-11-23 00:20:42 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠