Time of Update: 2018-12-05
// 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][
Time of Update: 2018-12-05
免費餡餅 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Problem Description都說天上不會掉餡餅,但有一天gameboy正走在回家的小徑上,忽然天上掉下大把大把的餡餅。說來gameboy的人品實在是太好了,這餡餅別處都不掉,就掉落在他身旁的10米範圍內。
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267將騎士和龍頭都按升序排序,按順序如果騎士值大於所有龍頭則可以繼續,如果可以殺掉所有龍頭則輸出騎士和否則不行。#include<iostream>#include<cstdio>#include<cstring>#include<algo
Time of Update: 2018-12-05
#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;
Time of Update: 2018-12-05
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--)
Time of Update: 2018-12-05
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]&
Time of Update: 2018-12-05
#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
Time of Update: 2018-12-05
#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
Time of Update: 2018-12-05
#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){
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
hdu 1394http://acm.hdu.edu.cn/showproblem.php?pid=1394用線段樹求逆序數,例如要求x的逆序數只需要訪問(x+1,n)段有多少個數,就是x的逆序數。還有就是求最小逆序數的時候有個巧妙的想法,當把x放入數組的後面,此時的逆序數應該為x沒放入最後面之前的逆序總數加上(n-x)再減去(x-1);sum =
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
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;
Time of Update: 2018-12-05
HDU-4325-Flowershttp://acm.hdu.edu.cn/showproblem.php?pid=4325成段更新加離散化線段樹這題做了快有一天了。。。。各種問題啊,開始建樹時沒有把查詢的節點加入樹中,結果在查詢時發現很多節點的資訊丟失了,糾結了半天去看了下別人的代碼,原來建樹時就應把查詢的節點加入,在做離散化時,將hash數組開到10^9,又超記憶體了,通不過編譯,囧,之後改成map映射,終於羞愧的A了(這題的資料可能比較弱,不加離散化也能過)#include<iost
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
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
Time of Update: 2018-12-05
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