| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 129754 | SamAnd | 어르신 집배원 (BOI14_postmen) | C++17 | 653 ms | 94176 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 500005;
int n, m;
set<int> a[N];
vector<int> v;
void dfs(int x)
{
while (1)
{
if (a[x].empty())
break;
int h = *a[x].begin();
a[x].erase(h);
a[h].erase(x);
dfs(h);
}
v.push_back(x);
}
bool c[N];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < m; ++i)
{
int x, y;
scanf("%d%d", &x, &y);
a[x].insert(y);
a[y].insert(x);
}
dfs(1);
stack<int> s;
for (int i = 0; i < v.size(); ++i)
{
if (c[v[i]])
{
printf("%d ", v[i]);
while (s.top() != v[i])
{
printf("%d ", s.top());
c[s.top()] = false;
s.pop();
}
printf("\n");
}
else
{
s.push(v[i]);
c[v[i]] = true;
}
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
