Time of Update: 2018-12-05
/*典型的2-sat題目二分半徑兩點x,y有衝突,就把x連一條到yy(即y的對立點),y連一條到xx然後求強聯通分量,如果存在x到xx屬於一個聯通分量,則不符合條件*/#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<map>
Time of Update: 2018-12-05
THE MATRIX PROBLEMTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3001 Accepted Submission(s): 784Problem DescriptionYou have been given a matrix CN*M, each element E of CN*M is positive and no
Time of Update: 2018-12-05
參考:http://hi.baidu.com/myzone2009/blog/item/9a3e7e1895046574dab4bdff.html題目大意:給你a, b, c, d, k; 找出這樣的一隊 x, y, 使得 gcd(x , y) = k, 並且x ∈[1, b], y ∈ [1, d], 問有多少對符合要求的(x,
Time of Update: 2018-12-05
#include<iostream>#include<cstdio>#include<vector>using namespace std;const int N=55009;int n,q,a,b,fa[N],vis[N],ans[N],v[N],Max[N],Min[N],up[N],down[N];vector<int> need[N],edge[N],kv[N];int find(int x){ if(x==fa[x])return
Time of Update: 2018-12-05
參考:http://boatswain.info/lovers/wordpress/?p=124本題給出了三個圓形,求一點,使得該點到三個圓的視角相同。 不存在,則輸出沒有解決方案。 本題的痛點是用類比退火的時候,如何逼近最優解。也就是說,如何使得三個視角越來越接近,=> 三個視角的方差最小。當想到了這個以後,接下來就是什麼情況輸出不存在了。很明顯,在無窮遠出必然是存在點的。排除無窮遠處,則該點必然在三個圓的裡面,也就是(The discs centers are not all
Time of Update: 2018-12-05
/*HDU 3062*/#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<map> #include<algorithm> using namespace std; const int MAXE=10000000
Time of Update: 2018-12-05
/*題意:給定n個點和範圍,在範圍內找到一個點,使得n個點到這個點的最小距離最大類比退火法類比退火的過程1 找到這些點所在的範圍,用兩個點框定(代碼中e1,e2兩個點)2 在這個範圍內產生NUM個點(NUM自定)3 對於每個產生的點i,在其周圍產生NUM個點,一旦有點優於i,則替換。4 縮小範圍D,若D<精度,退出,否則執行 35 遍曆所有NUM個點,找到val的最大值*/#include <iostream>#include <cstdio>#include
Time of Update: 2018-12-05
/*最大權閉包經典對於一個點連匯點,邊權為花費值,連源點,邊權為賺的的值兩個點有約束關係a->b,連單項邊b->a;賺的值的和減去最大流就是解*/#include <cstdio>#include <iostream>#include <memory.h>#include<queue>#include<set>#include<ctime>#include<algorithm>#include<
Time of Update: 2018-12-05
/*參考:http://blog.sina.com.cn/s/blog_64675f540100sehz.html題意:給定n個點,找到一個點,使得n個點到這個點的和值最小類比退火法類比退火的過程1 找到這些點所在的範圍,用兩個點框定(代碼中e1,e2兩個點)2 在這個範圍內產生NUM個點(NUM自定)3 對於每個產生的點i,在其周圍產生NUM個點,一旦有點優於i,則替換。4 縮小範圍D,若D<精度,退出,否則執行 35 遍曆所有NUM個點,找到val的最大值*/#include <
Time of Update: 2018-12-05
從第K 元素看資料結構這篇文章討論的是序列中第K 大或第K 小元素,由於第K 大元素可以轉化為求第N-K+1小元素(N 為序列的長度),所以,本文專註於討論第K 小元素。本文討論的幾個問題:1. 對給定整數序列,求該序列中第K 小的元素。2. 對某一整數序列,允許動態更改序列中的數。動態查詢序列中第K 小元素。3. 給定一個整數序列和若干個區間,回答該區間內第K 小元素。4. 對某一整數序列,允許動態更改序列中的數。動態查詢序列中的第K 小元素。【關鍵字】第K
Time of Update: 2018-12-05
Treasure MapTime Limit: 2 Seconds Memory Limit: 32768 KB Your boss once had got many copies of a treasure map. Unfortunately, all the copies are now broken to many rectangular pieces, and what make it worse, he has lost some of the pieces. Luckily,
Time of Update: 2018-12-05
參考:http://www.cppblog.com/pcfeng502/archive/2009/10/18/98902.aspx這道題在集訓手冊上標誌是“抽屜原理”,老實說,在看到這道題的具體解法之前,我還不知道為什麼是抽屜原理,這明明是判斷一些數的同餘嘛,後來才發現鴿籠原理的巧妙之處。 4 51 2 3 7 5 例如對於第一組資料,1 2 3 7 5模上4分別是:1 2 3 3
Time of Update: 2018-12-05
#include<cstdio>#include<queue>#include<cstring>#include<cstring>using namespace std;typedef __int64 type;const int kind=4; //每個節點的子節點的個數上限const int mod = 100000;const int size=109; //轉移矩陣的行大小class AC_auto{ public: int
Time of Update: 2018-12-05
/*我們要找到在a,b左下方點的個數和權值和,只需要把x座標不大於a的y值插入樹狀數組,然後統計y值小於b的個數個他們的權值和就行了。所以要得到正確答案,必須插入和查詢同時進行(離線操作)——只有只插入x不大於a的y值的情況下統計出來才是正確答案。當然,由於y值範圍大,值可能很稀疏,這樣無疑會影響到插入和查詢的時空效率。注意到,我們只關心比y小的個數和他們的權值,並不關心小多少之類的問題。所以把y按小到達映射成一個互異的升序數列可以很大得提高時空效率(離散化思想)統計區間(a1,b1),(a2,
Time of Update: 2018-12-05
poj3133#include <cstdio>#include <iostream>#include <cstring>using namespace std;const int hash_size=60007;const int INF=100000;int n, m;int map[20][20];int Pow[40];struct node {int hash_chart[hash_size], sz;int msk[hash_size];int
Time of Update: 2018-12-05
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<stack>#include<algorithm>#include<cmath>#include<map>using namespace std;const int MOD=1000000007;const
Time of Update: 2018-12-05
/*題目意思:找出這麼一些點x,滿足從1,2,3沿著各自的最短路走到x的路途上不可能相遇1 分別以1,2,3為起點求出1,2,3到各個點的最短路2 枚舉邊,到邊起點u的最短路為dis1,dis2,sis3,到終點v的最短路為Dis1,Dis2,Dis3 如果Disx==disx+邊權,那麼終點v必定不滿足條件,篩去3 找出未篩去並且1,2,3都可達的點 */#include <iostream>#include <cstdio>#include
Time of Update: 2018-12-05
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#include<vector>#include<stack>#include<map>#define MAX 50500using namespace std;int p;int a[150
Time of Update: 2018-12-05
/*判斷一個多邊形是否嚴格在一個凸包內(這個凸包上不存在共線的三點)把凸包上的點和多邊形上的點一起做一次凸包是產生,判斷產生的凸包和原來的是否是一個凸包就ok了注意的細節比較多
Time of Update: 2018-12-05
/*水貪心,不解釋*/#include <cstdio>#include <iostream>#include <memory.h>#include<queue>#include<set>#include<algorithm>using namespace std;int n,m;struct point{int Min,Max;}p[40009];bool cmp(point a,point b){if(a.Max!=b.