原创 codeforces 84E

#include<bits/stdc++.h> #define N 55 using namespace std; struct Node{ int x,y,bs,mas; string s; }; operator < (Node

原创 4428: [Nwerc2015]Debugging調試

#include<bits/stdc++.h> #define N 1000100 using namespace std; long long f[N],x,y; int n; long long dfs(int p){ if(

原创 NWERC 2015B/bzoj 4426 Better Productivity

#include<bits/stdc++.h> #define N 210 using namespace std; struct Node{int x,y;}a[N],b[N],c[N]; int dp[N][N]; int n,p,B

原创 UVA 1093 Castles

題目大意:太長不想說,自己看吧。 發現留守和死亡是沒有區別的,那麼把它們一起考慮。 考慮只有一個點的情況,那麼這個點需要的人數就是max(a,b+c),但是死亡的人數是b+c 那麼我們先把需要的人數和死亡的人數做一個pair。 然後考慮枚

原创 Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) B HIGH ROAD

構造題。題目大意:構造一棵有N個節點,其中K個是孩子節點的樹,讓它的直徑最小,並輸出這棵樹的所有邊和直徑。 不難發現,孩子節點越多,這棵樹的直徑就越小。那麼我們考慮刪去K個孩子節點後的樹。這棵樹的孩子節點數肯定不能超過K,所以就讓它的孩子

原创 codeforces 442D - Adam and Tree

題目大意: 給一棵樹上的每條邊染色,每種顏色只能用一次,一次染色樹上的一條鏈。 問(從根到所有節點經過的顏色的最大值)的最小值是多少。 樹是通過每次加一個點得到的,問每次加點之後的最小值是多少。 點數<=1,000,000 不難發現,答案

原创 Atcoder Grand Contest 013D piling Up

題目大意: 初始時有i個紅球(i∈[0,n])和n-i個藍球。進行m次操作,每次先任意選出一個球,然後再放入一個藍球和一個紅球,再任意選出一個球。問選出的球的序列有多少種可能?n,m∈[1,3000] 首先,我們用i表示當前紅球的數量:

原创 codeforces 571B

#include<bits/stdc++.h> #define N 300100 using namespace std; inline int read(){ int f=0,a=0;char ch=getchar(); while

原创 codeforces 115D

#include<bits/stdc++.h> #define N 2010 using namespace std; const int MOD=1e6+3; int n; string s; int dp[N][N]; int sum

原创 【SPOJ】NPC2016C - Strange Waca

Waca loves maths,.. a lot. He always think that 1 is an unique number. After playing in hours, Waca suddenly realize th

原创 Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A 題目忘了

題目大意: 反正就是字符串覆蓋,但是已經被覆蓋了就不會再被覆蓋了,問最終的字符串。 非常顯然可以用鏈表/並查集/線段樹做。這是比較顯然的做法。這裏我用優先隊列做了一發,效果還不錯。 首先需要了解堆的刪除操作和離線區間加。那麼我就用離線區間

原创 洛谷P2899 [USACO08JAN]手機網絡Cell Phone Network

#include<bits/stdc++.h> #define N 100100 using namespace std; const int INF=1008610086; int A[N],B[N],C[N]; int beg[N],

原创 codeforces 293B

#include<bits/stdc++.h> #define N 55 #define K 11 using namespace std; const int MOD=1e9+7; int jc[K],a[N][N]; int cu[N

原创 agc001D

#include<bits/stdc++.h> #define N 1010 using namespace std; int n,m; int a[N]; vector<int> s,w; int main(){ scanf("%d%

原创 Codeforces Round #124 (Div. 1) D. The Next Good String

#include<bits/stdc++.h> #define N 400100 using namespace std; typedef unsigned long long ULL; const ULL MOD=29; ULL cf[