Time of Update: 2018-12-05
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=589 簡單閉包。。。注意一下用scanf來讀入字元時getchar()使用就ok了#include<stdio.h>#include<string.h>int re1[30][30],re2[30][30];int main(){//freopen("a.txt","r",stdin);int t;scanf("%d",&t);int
Time of Update: 2018-12-05
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1905很DT的說。。。沒有看到原來Input後是有“.”的!!!靠!#include<stdio.h>#include<string.h>char str[1000001];int main(){while(scanf("%s",str)!=EOF){if(str[0]=='.')break;int len=strlen(str);int
Time of Update: 2018-12-05
http://poj.org/problem?id=1990這題調試了n久!!!就是因為變數名有點亂,自己也亂了。#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;int num_small[20010],sum_small[20010];int Max;struct node{ int val,pos;}
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=2063 忘了每次清空那幾個DT的數組導致wa。。。低級錯誤。。。囧 #include<stdio.h>#include<string>#define MAX 510bool path[MAX][MAX],visit[MAX];int match[MAX];bool searchpath(int s,int m){for(int i=1;i<=m;i++){if(path[s][i]
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=3015犯一些低級錯誤。。。例如忘了return,注意求大和求小的式子---【ans+=t[i].ch*(num_min*t[i].cx-sum_min +
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1394 先說一下逆序數的概念:在一個排列中,如果一對數的前後位置與大小順序相反,即前面的數大於後面的數,那末它們就稱為一個逆序。一個排列中逆序的總數就稱為這個排列的逆序數。逆序數為偶數的排列稱為偶排列;逆序數為奇數的排列稱為奇排列。如2431中,21,43,41,31是逆序,逆序數是4,為偶排列。 ——這是北大《高等代數》上的定義。題意是說給
Time of Update: 2018-12-05
http://poj.org/problem?id=3622無限orz把STL用得淋漓盡致的大牛。。。本題用貪心,先對cow的新鮮度進行降序,再對grass的新鮮度進行降序,方便待會在grass中尋找符合grass[j].first>=cow[i].first的grass注意pair的排序是firs比second優先,unique返回唯一元素的最後那個地址,還要注意輸出要long
Time of Update: 2018-12-05
還有些不懂,先放下#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include <algorithm>#include <iostream>#include
Time of Update: 2018-12-05
http://acm.hust.edu.cn/thx/problem.php?id=1422STL+DFS#include<iostream>#include<cstdio>#include<string.h>#include<vector>#include<map>#include<cmath>#include<stack>#include<queue>#include<algorithm&g
Time of Update: 2018-12-05
http://acm.hdu.edu.cn/showproblem.php?pid=1025利用貪心+二分去做,複雜度O(nlogn)#define N 500005int a[N],dp[N];//dp[len]表示長度為len的序列最後一個的最小值int main(){FRE; int n; int ca= 1; while(scanf("%d",&n)!=-1){ int i,j; for(i=0;i<n;i++){
Time of Update: 2018-12-05
這題網上大多建議反向topsort,不過也可以正向的,只是記錄的不是入度,而是出度!利用優先隊列每次取出label大的,下標從n往前記錄。注意:我代碼ans求出的只是1~n重量對應的標籤,題目中有For each test case output on a single line the balls' weights from label 1 to label N.所以還要轉化為重量從1~n所對應的標籤;還有,注意重邊!#include <vector>#include
Time of Update: 2018-12-05
http://poj.org/problem?id=3259用Bellman-Ford和SPFA均可以判負環。。。SPFA【856KB
Time of Update: 2018-12-05
#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include
Time of Update: 2018-12-05
關於二分匹配詳見http://blog.csdn.net/leolin_/archive/2011/05/04/6393259.aspx**************************************************************http://acm.hdu.edu.cn/showproblem.php?pid=2444 //構造的二分圖雖然是多解的,但是任意一個二分圖的最大匹配數相等#include<iostream>using namespace
Time of Update: 2018-12-05
這題很基礎也很經典,不過個人認為有一個非常容易出錯的地方,就是矛盾Inconsistency的優先順序比不確定的優先順序高,因為當前有矛盾就立即跳出,而當前有多個點入度為0就不能立即輸出,有可能後來加入的線段可以確定唯一答案,就像一樣。。。很陰險!wa了幾次才得以ac。原本想用隊列,但是不好搞#include <vector>#include <list>#include <map>#include <set>#include <queue&
Time of Update: 2018-12-05
題目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1029題目大意是說給出a數組,對於b中的每一個在a中找出最小範圍使得ai<=b<a(i+1),注意Print a blank line after each test case.這一句話!開始沒看到結果WA了,杯具自敲的二分#include<iostream>using namespace std;#include<algorithm>
Time of Update: 2018-12-05
簡單的topsort,不解釋!可用隊列做,也可用for遍曆!#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include <bitset>#include
Time of Update: 2018-12-05
http://acm.timus.ru/problem.aspx?space=1&num=1149類比,不解釋。#include <vector>#include <list>#include <map>#include <set>#include <queue>#include <string.h>#include <deque>#include <stack>#include
Time of Update: 2018-12-05
文章目錄 紀念下第一道TC題。。。那格式實在很蛋疼,很不習慣Problem Statement Definition Constraints Examples 紀念下第一道TC題。。。那格式實在很蛋疼,很不習慣Problem Statement You are given a simple paragraph containing a number of sentences, the original person who
Time of Update: 2018-12-05
把它轉化為有限硬幣的模型只有3鐘情況,遍曆到sum就okhttp://acm.hdu.edu.cn/showproblem.php?pid=1085#include<stdio.h>#include<string>int c1[10000],c2[10000];int num[3]={1,2,5},m[3];int main(){int a,b,c;while(scanf("%d%d%d",&a,&b,&c) &&(a+b+c)){