↓ Skip to main content
  1. Posts/

高级搜索专题

·295 words·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

基础的搜索BFS和DFS,自己找题切吧…

高级搜索的题集就在下面,自己看着办吧…

努力爆搜,努力剪枝吧~~~


【Level 1】

HDOJ-1429 胜利大逃亡(续)  HDOJ-1885 Key Task HDOJ-1226 超级密码 HDOJ-1664 Different Digits HDOJ-2821 Pusher HDOJ-2128 Tempter of the Bone II HDOJ-3533 Escape HDOJ-4101 Ali and Baba HDOJ-3839 Ancient Messages HDOJ-1685 Booksort HDOJ-2614 Beat HDOJ-3309 Roll The Cube HDOJ-1067 Gap HDOJ-2181 哈密顿绕行世界问题 HDOJ-2437 Jerboas HDOJ-2102 A计划 HDOJ-1195 Open the Lock HDOJ-3295 An interesting mobile game HDOJ-2259 Continuous Same Game(2) HDOJ-3681 Prison Break HDOJ-3085 Nightmare Ⅱ

【Level 2】 POJ-1475 Pushing Boxes POJ-3635 Full Tank? POJ-2044 Weather Forecast POJ-2449 Remmarguts’ Date POJ-1324 Holedox Moving POJ-3322 Bloxorz I POJ-2308 Dearboy’s Puzzle POJ-2688 Cleaning Robot POJ-1376 Robot POJ-1190 生日蛋糕 POJ-1184 聪明的打字员 HDOJ-4012 Paint on a Wall HDOJ-3766 Knight’s Trip HDOJ-2605 Snake HDOJ-3121 FreeOpen HDOJ-3900 Unblock Me HDOJ-1732 Push Box HDOJ-2913 Traveling Cube HDOJ-3001 Travelling HDOJ-4090 GemAnd Prince

【Level 3】 HDOJ-1401 Solitaire HDOJ-4127 Flood-it! HDOJ-1560 DNA sequence HDOJ-2808 Islands HDOJ-1430 魔板 HDOJ-1043 Eight HDOJ-3567 Eight II HDOJ-1667 The Rotation Game HDOJ-2234 无题I HDOJ-1813 Escape from Tetris HDOJ-2918 Tobo or not Tobo HDOJ-3459 Rubik 2×2×2 HDOJ-2953 Rubiks Cube ZOJ-2477 Magic Cube HDOJ-2691 2-Dimensional Rubik’s Cube HDOJ-2467 Deja vu HDOJ-2485 Destroying the bus stations

Related

hdu 5305 Friends (dfs)

·314 words·1 min
dfs 1A 代码实现 1/************************************************************************* 2 > File Name: code/whust/#9/K.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月05日 星期三 15时02分30秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30const int inf = 0x7fffffff; 31int n ,m,ans; 32int d[50]; 33int on[50],off[50]; 34int u[50],v[50]; 35 36bool ok(int x,int y) 37{ 38 if ( !d[x] && !d[y] && on[x] == off[x] && on[y] == off[y] ) 39 return true; 40 if ( !d[x] && d[y] && on[x] == off[x] ) 41 return true; 42 if ( d[x] && !d[y] && on[y] == off[y] ) 43 return true; 44 if ( d[x] && d[y] ) 45 return true; 46 return false; 47} 48 49void dfs ( int i) 50{ 51 if (i==m) 52 { 53 ans++; 54 return; 55 } 56 int x = u[i]; 57 int y = v[i]; 58 d[x]--; 59 d[y]--; 60 on[x]++; 61 on[y]++; 62 if (ok(x,y)) 63 dfs (i+1); 64 on[x]--;on[y]--; 65 off[y]++;off[x]++; 66 if ( ok( x,y)) 67 dfs (i+1); 68 off[y]--; 69 off[x]--; 70 d[x]++; 71 d[y]++; 72} 73 74int main ( ) 75{ 76 int T; 77 cin>>T; 78 while ( T-- ) 79 { 80 ans = 0; 81 scanf ("%d %d",&n,&m); 82 memset (d,0,sizeof(d)); 83 memset (on,0,sizeof(on)); 84 memset (off,0,sizeof(off)); 85 for ( int i = 0 ; i < m ; i++ ) 86 { 87 scanf ("%d%d",&u[i],&v[i]); 88 d[u[i]]++; 89 d[v[i]]++; 90 } 91 dfs (0); 92 printf ( "%d\n" , ans ); 93 } 94}