POJ-3259-Wormholes

POJ-3259-Wormholeshttp://poj.org/problem?id=3259bellman_ford判斷是否有負環#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define MAX 0x7fffffffstruct edge{int x,y,v;}edge[6000];int m,n,w;int

POJ-2823-Sliding Window

POJ-2823-Sliding Windowhttp://poj.org/problem?id=2823求區間的最大值與最小值,線段樹即可,C++過了,G++逾時,囧#include<iostream>#include<cstring>#include<cstdio>#include<cstdlib>using namespace std;#define N 1000005struct cam{int x;int y;int min;int

POJ-2828-Buy Tickets

POJ-2828-Buy Ticketshttp://poj.org/problem?id=2828線段樹,逆序插入#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 200010struct cam{int x,y;int num;}list[N*8];int pos[N],value[N],ans[N]

POJ-1204-Word Puzzles

POJ-1204-Word Puzzleshttp://poj.org/problem?id=1204字典樹加深搜#include<iostream>#include<cstring>#include<cstdio>#include<cstdlib>using namespace std; char map[1005][1005];int n1,n2;int xx,yy;int dirx[8]={-1,-1,0,1,1,1,0,-1};int

POJ-1679-The Unique MST

POJ-1679-The Unique MSThttp://poj.org/problem?id=1679次小產生樹,prim稍作改變即可,每次加入新的頂點時,如果有不止一條權值最小的最短邊,則說明最小產生樹不只一種#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 105#define INF 99999

POJ-2728-Desert King

POJ-2728-Desert Kinghttp://poj.org/problem?id=2728有N個村莊,給出每個村莊的座標和海拔,,benifit為兩點之間的距離,cost為兩點的高度差,現在要求一棵樹使得 cost / benift 最小,即求一個最優比例產生樹第一次遇見這種產生樹,在網上找了個解法假設sigma(h)/sigma(l)==K 均值K可取,即:

POJ-1273-Drainage Ditches

POJ-1273-Drainage Ditcheshttp://poj.org/problem?id=1273基本的最大流,Ford-Fulkerson演算法,按LRJ的白書寫的#include<iostream>#include<cstring>#include<queue>using namespace std;#define INF 0x7fffffffint main(){int n,m;int from,to,w,f;int u,v;int cap[

POJ-2195-Going Home

POJ-2195-Going Homehttp://poj.org/problem?id=2195最小費用最大流,假想一個源點,一個匯點代碼模仿網上的寫的,還要再好好研究哇#include<stdio.h>#include<string.h>#include<math.h>#define maxn 300#define INF 0x7fffffffint min(int x,int y){return x<y?x:y;}struct node

POJ-1511-Invitation Cards

POJ-1511-Invitation

【HDU1272】小希的迷宮解題報告,資料+思路+代碼

#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#define INPUTusing namespace std;/* Problem : HDU1272 - 小希的迷宮 State : 54213202012-02-26 23:40:14Accepted127262MS1636K3853 BG++c0de4fun

HDU-1247-Hats Words

HDU-1247-Hats Wordshttp://acm.hdu.edu.cn/showproblem.php?pid=1247還是字典樹的題目,將每個單詞分成兩個單詞即可,尋找是否兩個單詞均在字典樹中注意建樹的時和之前略有區別,這題在插入單詞時,只需記錄單詞結尾的節點,不需要記錄一個單詞的所有首碼#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using

HDU-2846-Repository

HDU-2846-Repositoryhttp://acm.hdu.edu.cn/showproblem.php?pid=2846題意是給出一些模式串,再給出幾個詢問,詢問給出的字串在多少個模式串中出現比如字串abc所含的字串有a,ab,abc,b,bc,c可用字典樹解決,字典樹能很好的處理首碼出現的次數,所以可將模式串分解,依次插入需要注意的是對於同一個模式串的不同子串可能有相同的首碼,為了避免多次計算,可以添加字典樹節點的資訊,添加num記錄最後插入的字串是第num個模式串的子串#inclu

HDU-1251-統計難題

HDU-1251-統計難題http://acm.hdu.edu.cn/showproblem.php?pid=1251基本的字典樹,字典樹又稱單詞尋找樹,Trie樹,是一種樹形結構,是一種雜湊樹的變種。典型應用是用於統計,排序和儲存大量的字串(但不僅限於字串),所以經常被搜尋引擎系統用於文本詞頻統計。它的優點是:利用字串的公用首碼來節約儲存空間,最大限度地減少無謂的字串比較,查詢效率比雜湊表高。如所示,每一個紅色節點都一個單詞,白色節點表示公用首碼#include<iostream>

【poj】1363-Rails

#include <iostream>#include <stdio.h>#include <memory.h>const int MAXSIZE = 10000;using namespace std;int trains[MAXSIZE];int orders[MAXSIZE];int stacks[MAXSIZE];int top;int main(){// freopen("b:\\acm\\input.txt","r",stdin);

POJ-3264-Balanced Lineup

POJ-3264-Balanced Lineuphttp://poj.org/problem?id=3264線段樹,求區間的最大值與最小值之差#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 50005#define INF 0x7ffffffint num[N];struct cam{int x; //起點int y; //終點int min; //最小值int max;

【ACM-POJ】poj2386,Lake Counting

#include <iostream>#include <stdio.h>//#define DBGusing namespace std;const int MAXSIZE = 10000;char map[MAXSIZE][MAXSIZE];int N,M;unsigned long LakeCounts;bool iFirstLake = true;bool iCounted = true;void dfs(int x,int y){ int m,n;

POJ-3468-A Simple Problem with Integers

POJ-3468-A Simple Problem with Integershttp://poj.org/problem?id=3468成段更新線段樹#include<stdio.h>#include<string.h>#include<stdlib.h>#define N 100005int num[N];struct cam{int x; //起點int y; //終點__int64 sum; //和int add;

【HDU2717】-Catch that cow

題目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2717這點需要特別注意的是HDU特別坑爹,POJ上是單組資料,多點測試,HDU是一點測試,多組資料!所以在POJ上把while(cin >> N >> K)去掉也是AC的,簡單的BFS#include <iostream>#include <stdio.h>#include <queue>#include

POJ-2528-Mayor’s posters

POJ-2528-Mayor's postershttp://poj.org/problem?id=2528線段樹的離散化,離散化就相當於是先做映射,然後再建樹對於題目給出的測試資料1 42 68 103 47 10將端點取出並且排序,去掉相同的座標,即1,2,3,4,6,7,8,10,那麼1,2,3,4,6,7,8,10可以離散化為1,,2,3,4,5,6,7,8 題目給出的區間可以表示為1 42 57 83 46

【POJ2796】代碼,非原創,參考的別人的文章

#include <iostream>#include <stdlib.h>#include <stdio.h>/* Reference:http://www.cnblogs.com/youngxiao/archive/2010/05/19/1739381.html.THX A LOT TO YOU.  author:YuXun Lu(A.K.A Kyle Broflovlaski) problem:poj2796 Begin Time:

總頁數: 61357 1 .... 13475 13476 13477 13478 13479 .... 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.