# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
31496 | aome | 어르신 집배원 (BOI14_postmen) | C++14 | 6 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
10 15
1 3
5 1
2 3
9 2
3 4
6 3
4 5
7 4
4 8
5 7
8 5
6 7
7 8
8 10
10 9
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 205
struct data {
int u;
list<data>::iterator it;
data(int _u): u(_u) {};
};
int n, m;
list<data> a[N];
deque<int> path;
void add_edge(int u, int v) {
a[u].push_front(data(v));
a[v].push_front(data(u));
a[u].begin()->it = a[v].begin();
a[v].begin()->it = a[u].begin();
}
ostream& operator << (ostream &os, vector<int>&x) {
for (int i = 0; i < x.size(); i++) os << x[i] << sp;
return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
cout << x.fi << sp << x.se << sp;
return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
for (int i = 0; i < x.size(); i++) os << x[i] << endl;
return os;
}
bool in[N];
void find_path(int u) {
while (a[u].size() > 0) {
int v = a[u].front().u;
list<data>::iterator it = a[u].front().it;
a[v].erase(it);
a[u].pop_front();
find_path(v);
}
if (in[u]) {
while (!path.empty() && path.back() != u) {
cout << path.back() << sp; in[path.back()] = false;
path.pop_back();
}
cout << path.back() << sp; in[path.back()] = false; path.pop_back();
cout << endl;
}
path.push_back(u); in[u] = true;
}
signed main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
add_edge(u, v);
}
find_path(1);
// for (int i = 0; i < path.size(); i++) cout << path[i] << sp;
// cout << endl;
}
컴파일 시 표준 에러 (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... |