HDU-1242-Rescue

HDU-1242-Rescuehttp://acm.hdu.edu.cn/showproblem.php?pid=1242bfs即可,可能有多個’r’,而’a’只有一個,從’a’開始搜,找到的第一個’r’即為所求需要注意的是這題寬搜時存在障礙物,遇到’x’點是,時間+2,如果用普通的隊列就並不能保證每次出隊的是時間最小的元素,所以要用優先隊列,第一次用優先隊列,還不熟練哇優先隊列(priority_queue)的基本操作:empty(); 隊列為空白返回1pop();   出隊push();  

POJ-3984-迷宮問題

POJ-3984-迷宮問題http://poj.org/problem?id=3984用BFS求最短路勁,記錄每一個狀態之前的狀態,輸出路勁即可#include<stdio.h>#include<string.h>#include<stdlib.h>int map[5][5];int visit[5][5];int pre[100]; //記錄每一個狀態的前一個狀態struct cam{int x;int y;}list[100];int dir[4][2]

最小路勁覆蓋 最小點覆蓋 最大獨立集

最小路勁覆蓋一個不含圈的有向圖G 中,G的一個路徑覆蓋是一個其結點不相交的路徑集合P,圖中的每一個結點僅包含於P中的某一條路徑。路徑可以從任意結點開始和結束,且長度也為任意值,包括0。在有向非循環圖中    最小路徑覆蓋數 = 頂點總數—最大匹配數POJ-1422-Air Raidhttp://poj.org/problem?id=1422#include<stdio.h>#include<string.h>#include<stdlib.h>int map[

POJ-2251-Dungeon Master

POJ-2251-Dungeon Masterhttp://poj.org/problem?id=2251基本的三維BFS,用隊列寫的#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<queue>using namespace std;int n1,n2,n3;char map[40][40][40];int visit[40][40

HDU-3081-Marriage Match II

HDU-3081-Marriage Match IIhttp://acm.hdu.edu.cn/showproblem.php?pid=3081女生和男生配對,有些女生相互是朋友,每個女生也可以跟她朋友所配對的男生配對每次配對,每個女生都要跟不同的男生配對。問最多能配對幾輪。最大流,用並查集處理女生之間的朋友關係,最少配0輪,最多配n輪,二分解之,源點向女生建邊,男生向匯點建邊,容量均為mid,女生跟所有能配對的男生連線,容量為1,如果最大流 = mid * n,那mid就就能做到mid輪配對#

HDU-1272-小希的迷宮

HDU-1272-小希的迷宮http://acm.hdu.edu.cn/showproblem.php?pid=1272基本的並查集#include<iostream>#include<cstdio>using namespace std;#define N 100010int f[N];int mark[N];int find(int x){int r=x;while(f[r]!=r)r=f[r];f[x]=r;return f[x];}void merege(int

HDU-1427-速算24點

HDU-1427-速算24點http://acm.hdu.edu.cn/showproblem.php?pid=14274個數通過 +,—,*,/和加括弧,計算得24,枚舉數字和運算子,DFS即可,注意題目要求計算過程中都不能出現小數,所以做除法時稍作處理枚舉數組可用algorithm裡的next_permutationThe next_permutation() function attempts to transform the given range of elements [start,

POJ-2488-A Knight’s Journey

POJ-2488-A Knight's Journeyhttp://poj.org/problem?id=2488給一個n1*n2的棋盤,從(0,0)出發,每次走日字形,能否不重複的遍曆所有的點用DFS即可,需要注意搜尋的方向要按字典序 #include<stdio.h>#include<string.h>#include<stdlib.h>int n1,n2;int xx[30],yy[30];int visit[30][30];int flag;int

HDU-1598-find the most comfortable road

HDU-1598-find the most comfortable roadhttp://acm.hdu.edu.cn/showproblem.php?pid=1598並查集加貪心#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 1010#define INF 0x7fffffffstruct cam{

POJ-1088-滑雪

POJ-1088-滑雪http://poj.org/problem?id=1088從每一個點深搜,果然逾時了,因為這要重複計算很多次,最佳化一下,將搜尋過的點記錄下來,避免重複計算即可逾時的代碼#include<stdio.h>#include<string.h>#include<stdlib.h>int map[105][105];int n1,n2,ans;int dir[4][2]={{0,-1},{0,1},{-1,0},{1,0}};int

codeforces-320A-Magic Numbers

http://codeforces.com/problemset/problem/320/AA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore14144, 141414 and 1411 are magic numbers but 1444, 514 and 414

HDU-3635-Dragon Balls

HDU-3635-Dragon Ballshttp://acm.hdu.edu.cn/showproblem.php?pid=3635並查集,路徑壓縮來更新轉移的次數#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 10005struct cam{int f;int num;int

HDU-4027-Can you answer these queries

HDU-4027-Can you answer these querieshttp://acm.hdu.edu.cn/showproblem.php?pid=4027線段樹成段更新,n比較小,更新到每個葉子節點,注意1開根號後仍是1,不需要再更新#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<cmath>using

HDU-1298-T9

HDU-1298-T9http://acm.hdu.edu.cn/showproblem.php?pid=1298很好的一題,字典樹+DFS,思路參考swm8023大牛的題意是類比手機IME,給出幾個單詞即頻度,再給出幾個數字串,確定對於給定的一個數字串,每輸入一個數字,將顯示什麼字元本題的數字串的每一個數字均代表一個字母,而不是平常的手機,多個數字可能代表一個字母,首先可將給出的單詞即頻度記錄到字典樹中,對於數字串進行DFS,尋找其可能表示的頻度最大的字串例如    ab  2       

HDU-4107-Gangster

HDU-4107-Gangsterhttp://acm.hdu.edu.cn/showproblem.php?pid=4107線段樹的成段更新,這題可以記錄一個區間的最大值和最小值,若一個區間的最大值小於p,則增量增加c,若區間的最小值大於等於p,則增量增加2*c,G++逾時,C++過了#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#define N 200

HDU-1075-What Are You Talking About

HDU-1075-What Are You Talking Abouthttp://acm.hdu.edu.cn/showproblem.php?pid=1075字典樹#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;struct node{int count;node *childs[26];char

HDU-3397-Sequence operation

HDU-3397-Sequence operationhttp://acm.hdu.edu.cn/showproblem.php?pid=3397線段樹,對區間的多個操作#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 100010struct cam{int x;int y;int len;int

HDU-4038-Saving Princess Claire

HDU-4038-Saving Princess

HDU-1240-Asteroids!

HDU-1240-Asteroids!http://acm.hdu.edu.cn/showproblem.php?pid=1240三維的BFS,和二維的差不多#include<stdio.h>#include<string.h>#include<stdlib.h>char map[12][12][12];int visit[12][12][12];int ans[12][12][12];int n;int dir[6][3]={{1,0,0},{-1,0,0}

HDU-1711-Number Sequence

HDU-1711-Number Sequencehttp://acm.hdu.edu.cn/showproblem.php?pid=1711KMP模版#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define N 1000005#define M 10005int a[N],b[M],nextt[M];int n,m;void getnext(){int

總頁數: 61357 1 .... 13476 13477 13478 13479 13480 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.