提出 #1262222
ソースコード 拡げる
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;
#define fto(i,a,b) for (int i = (a); i <= b; i++)
#define fdw(i,a,b) for (int i = (a); i >= b; i--)
#define rep(i,a) for(int i = 0; i < a; i++)
#define read(a) cin >> a
#define read2(a, b) cin >> a >> b
#define read3(a, b, c) cin >> a >> b >> c
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define write(a) cout << a << " "
#define writeln(a) cout << a << "\n"
#define PI 3.14159265
#define oo 1000000000
#define debug(a) cout << #a << " = " << a << endl
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define next thongdeptrai
#define prev thongbachuthegioi
#define y1 thongsieucapvutru
#define y0 thongnotgay
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;
#define maxn 100005
using namespace std;
int n, m, x, y;
vector<int> AdjList[maxn];
int isPath[maxn];
vi res;
void solve(int u) {
if (isPath[u] == 0) res.pb(u);
isPath[u] = 1;
fto(i, 0, AdjList[u].size() - 1) {
int v = AdjList[u][i];
if (isPath[v] == 0) {
solve(v);
break;
}
}
}
int main() {
// freopen("in.inp", "r", stdin);
read2(n, m);
fto(i, 1, m) {
read2(x, y);
AdjList[x].pb(y);
AdjList[y].pb(x);
}
//how to prove that this path is always true??
solve(1);
int pos = res.size();
solve(1);
cout << res.size() << endl;
fdw(i, res.size() - 1, pos) cout << res[i] << " ";
fto(i, 0, pos - 1) cout << res[i] << " "; cout << endl;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample_01.txt |
AC |
2 ms |
2560 KiB |
| sample_02.txt |
AC |
2 ms |
2560 KiB |
| sample_03.txt |
AC |
2 ms |
2560 KiB |
| subtask_1_01.txt |
AC |
79 ms |
4864 KiB |
| subtask_1_02.txt |
AC |
21 ms |
3200 KiB |
| subtask_1_03.txt |
AC |
71 ms |
4992 KiB |
| subtask_1_04.txt |
AC |
85 ms |
4864 KiB |
| subtask_1_05.txt |
AC |
83 ms |
4864 KiB |
| subtask_1_06.txt |
AC |
86 ms |
4992 KiB |
| subtask_1_07.txt |
AC |
87 ms |
5888 KiB |
| subtask_1_08.txt |
AC |
86 ms |
5888 KiB |
| subtask_1_09.txt |
AC |
111 ms |
10104 KiB |
| subtask_1_10.txt |
AC |
26 ms |
3328 KiB |
| subtask_1_11.txt |
AC |
32 ms |
3328 KiB |
| subtask_1_12.txt |
AC |
2 ms |
2560 KiB |
| subtask_1_13.txt |
AC |
2 ms |
2560 KiB |