Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
90 lines (78 loc) · 1.7 KB

File metadata and controls

90 lines (78 loc) · 1.7 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
ID: xieke.b1
PROB: fence
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string.h>
#include <cmath>
using namespace std;
ifstream fin("fence.in");
ofstream fout("fence.out");
typedef pair<int, int> pii;
const int MAXN = 501;
const int INF = 999999999;
int F;
vector< pii > g[MAXN];
vector<int> cir;
void dfs(int cur_pos){
cout<<"at "<<cur_pos<<endl;
int sz = g[cur_pos].size();
for(int i=0; i< sz; i++){
if(g[cur_pos][i].second == 0){
g[cur_pos][i].second = 1;
int v = g[cur_pos][i].first;
for(int k=0; k<g[v].size(); k++){
if( g[v][k].first== cur_pos && g[v][k].second==0){
cout<<"mark"<<endl;
g[v][k].second=1;break;
}
}
dfs(g[cur_pos][i].first);
}
}
cout<<"push "<<cur_pos<<endl;
cir.push_back(cur_pos);
}
void work(){
//odd vetice?
int start_pos = -1;
for(int i=1; i<MAXN; i++){
if((g[i].size() & 1) ==1){
start_pos = i;
break;
}
}
if(start_pos==-1){
for(int i=1; i<=500; i++){
if(g[i].size()>0){
start_pos = i;
break;
}
}
}
dfs(start_pos);
reverse(cir.begin(), cir.end());
for(int i=0; i<cir.size(); i++){
fout<<cir[i]<<endl;
}
}
int main(){
fin>>F;
for(int i=0; i<F; i++){
int a,b;
fin>>a>>b;
g[a].push_back(pii(b,0));
g[b].push_back(pii(a,0));
}
for(int i=0; i<MAXN; i++){
sort(g[i].begin(), g[i].end());
}
work();
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.