# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
172124 | davitmarg | 어르신 집배원 (BOI14_postmen) | C++17 | 595 ms | 52796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
;
int n, m;
int used[500005], edge[500005];
vector<pair<int, int>> g[500005];
vector<int> path;
void euler(int v)
{
while (!g[v].empty())
{
int to = g[v].back().first;
int id = g[v].back().second;
g[v].pop_back();
if (used[id])
continue;
used[id] = 1;
euler(to);
}
path.PB(v);
}
void add(int a, int b, int id)
{
g[a].PB(MP(b, id));
g[b].PB(MP(a, id));
}
void print(vector<int> &s)
{
while (!s.empty())
{
printf("%d ", s.back());
s.pop_back();
}
printf("\n");
}
int main()
{
cin >> n >> m;
while (m--)
{
int a, b;
scanf("%d%d", &a, &b);
add(a, b, m);
}
euler(1);
vector<int> s;
for (int i = 0; i <= n; i++)
used[i] = 0;
for (int i = 0; i < path.size(); i++)
{
if (!used[path[i]])
{
s.PB(path[i]);
used[path[i]] = 1;
}
else
{
printf("%d ", path[i]);
while (s.back() != path[i])
{
printf("%d ", s.back());
used[s.back()] = 0;
s.pop_back();
}
cout << endl;
}
}
return 0;
}
/*
6 6
1 2
1 3
1 4
1 5
3 2
4 5
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |