zoj 1649 BFS

// zoj 1649#include<stdio.h>#include<queue>#include<string.h>using namespace std;#define MAXN 200#define INF 1000000struct point{ int x,y; int step,time;};queue<point> Q;int N,M,ax,ay;char map[MAXN][MAXN];int time[MAXN][

HDU1176 (簡單DP)

                                               免費餡餅              Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Problem Description都說天上不會掉餡餅,但有一天gameboy正走在回家的小徑上,忽然天上掉下大把大把的餡餅。說來gameboy的人品實在是太好了,這餡餅別處都不掉,就掉落在他身旁的10米範圍內。

Highly divisible triangular number( Problem 12)

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...Let us list the factors of the first

uva11292 – Dragon of Loowater

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267將騎士和龍頭都按升序排序,按順序如果騎士值大於所有龍頭則可以繼續,如果可以殺掉所有龍頭則輸出騎士和否則不行。#include<iostream>#include<cstdio>#include<cstring>#include<algo

騰訊馬拉松-屌絲的逆襲-hdu4500

#include<stdio.h>#include<stdlib.h>int x[21][21];int main(){ int i,j,n,m; // freopen("input.txt","r",stdin); while(scanf("%d%d",&n,&m)!=EOF) { int s[21][21]= {0}; if(m==0||n==0) break;

hdu1702 list or stack+queue

http://acm.hdu.edu.cn/showproblem.php?pid=1702#include<iostream>#include<cstdio>#include<cstring>#include<list>using namespace std;int main(){ // freopen("1.txt","r",stdin); int n; scanf("%d",&n); while(n--)

hdu 1213 並查集

http://acm.hdu.edu.cn/showproblem.php?pid=1213#include<iostream>#include<cstdio>using namespace std;#define N 1000int father[N];void ufset(){ for(int i=0;i<N;i++) father[i]=-1;}int find(int x){ int s; for(s=x;father[s]&

Hdu1166– 線段樹模板

#include<iostream>#include<cstdio>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=555555;int sum[maxn<<2];void pushup(int rt){ sum[rt]=sum[rt<<1]+sum[rt<<1|1];}void

joj2410: The knight problem

#include<iostream>#include<cstdio>#include<queue>using namespace std;typedef struct Point{ int x, y;}POINT;queue <POINT> me;POINT Begin , End;bool visited[9][9];bool flag;int ans;int movei[8]= {2,-2,1,-1,2,-2,1,-1};int

Hdu1754-線段樹-單點更新

#include<iostream>#include<cstdio>#include<algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=200005;int MAX[maxn<<2];void pushup(int rt){

HDU-3074-Multiply game

HDU-3074-Multiply gamehttp://acm.hdu.edu.cn/showproblem.php?pid=3074求區間元素的乘積,可以更新元素,線段樹即可#include<stdio.h>#include<string.h>#include<stdlib.h>#define Mod 1000000007#define N 50005int num[N];struct cam{int x; //起點int y; //終點__int64

hdu1394 線段樹求最小逆序數

hdu 1394http://acm.hdu.edu.cn/showproblem.php?pid=1394用線段樹求逆序數,例如要求x的逆序數只需要訪問(x+1,n)段有多少個數,就是x的逆序數。還有就是求最小逆序數的時候有個巧妙的想法,當把x放入數組的後面,此時的逆序數應該為x沒放入最後面之前的逆序總數加上(n-x)再減去(x-1);sum =

HDU-1010-Tempter of the Bone

HDU-1010-Tempter of the Bonehttp://acm.hdu.edu.cn/showproblem.php?pid=1010給這題折騰了半天啊,剛開始用BFS寫的,總是WA,後來發現這題要求在給定的時間點到達,不能早,也不能遲,而BFS每次求出的是最短時間,不合題意,於是轉用DFS,剪枝的方法是參考HDU的PPT寫的,居然還要考慮奇偶性可以把map看成這樣: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0

HDU-4068-SanguoSHA

HDU-4068-SanguoSHAhttp://acm.hdu.edu.cn/showproblem.php?pid=4068字串類比,枚舉自己和對手的牌的全排列即可#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int map[10][10];char str[10][25];int

HDU-1754-I Hate It

HDU-1754-I Hate Ithttp://acm.hdu.edu.cn/showproblem.php?pid=1754查詢區間的最大值,並可以更新線段樹即可,為區間[1,5]的線段樹#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 200005int num[N];struct cam{int x; //起點int y; //終點int max;

HDU-4325-Flowers

HDU-4325-Flowershttp://acm.hdu.edu.cn/showproblem.php?pid=4325成段更新加離散化線段樹這題做了快有一天了。。。。各種問題啊,開始建樹時沒有把查詢的節點加入樹中,結果在查詢時發現很多節點的資訊丟失了,糾結了半天去看了下別人的代碼,原來建樹時就應把查詢的節點加入,在做離散化時,將hash數組開到10^9,又超記憶體了,通不過編譯,囧,之後改成map映射,終於羞愧的A了(這題的資料可能比較弱,不加離散化也能過)#include<iost

HDU-1244-Oil Deposits

HDU-1244-Oil Depositshttp://acm.hdu.edu.cn/showproblem.php?pid=1241基本的DFS#include<stdio.h>#include<string.h>#include<stdlib.h>char map[105][105];int n,m;int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};int

HDU-2795-Billboard

HDU-2795-Billboardhttp://acm.hdu.edu.cn/showproblem.php?pid=2795線段樹,建樹時要注意範圍#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 200005int h,w;struct cam{int x;int y;int

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-2612-Find a way

HDU-2612-Find a wayhttp://acm.hdu.edu.cn/showproblem.php?pid=2612求2個點到KFC的距離之和,使其最小,可用2次BFS,分別求出2個點到各個KFC的最短距離,然後找出和最小的即可#include<stdio.h>#include<string.h>#include<stdlib.h>#define max 0x7fffffffint n,m;char map[250][250];int

總頁數: 61357 1 .... 7796 7797 7798 7799 7800 .... 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.