标签:strong bsp ring font family class mil display ret
http://hihocoder.com/problemset/problem/1181
1 #include <iostream> 2 using namespace std; 3 int n, m, a, b; 4 int map[1005][1005], vis[1005]; 5 void dfs(int x){ 6 for(int i = 1; i <= n; i++) if(map[x][i] != 0){ 7 map[x][i] --; 8 map[i][x] --; 9 dfs(i); 10 } 11 cout << x << " "; 12 } 13 int main(){ 14 cin >> n >> m; 15 for(int i = 0; i < m; i++){ 16 cin >> a >> b; 17 map[a][b] ++, map[b][a] ++; 18 vis[a] ++, vis[b] ++; 19 } 20 int x = 1; 21 for(int i = 1; i <= n; i++) if(vis[i] & 1){ 22 x = i; 23 break; 24 } 25 dfs(x); 26 }
http://hihocoder.com/problemset/problem/1182
1 #include <iostream> 2 #include <string.h> 3 using namespace std; 4 int n, cot = 0; 5 int map[20000][2], num[40000]; 6 void dfs(int x){ 7 for(int i = 0; i < 2; i++){ 8 int xx = map[x][i]; 9 if(xx > -1){ 10 map[x][i] = -1; 11 dfs(xx); 12 } 13 } 14 num[++cot] = x; 15 } 16 int main(){ 17 cin >> n; 18 n = 1<<(n-1); 19 memset(map, -1, sizeof(map)); 20 for(int i = 0; i < n; i++){ 21 int j = (i<<1)&(n-1); 22 map[i][0] = j; 23 map[i][1] = j+1; 24 } 25 dfs(0); 26 while(--cot){ 27 cout<<(num[cot]&1); 28 } 29 return 0; 30 }
只有不断学习才能进步!
标签:strong bsp ring font family class mil display ret
原文地址:https://www.cnblogs.com/wenbao/p/5886650.html