原创 hdu 3001 Travelling//狀態壓縮DP
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int inf = 100000000; int tri[12
原创 zoj 3471 Most Powerful //狀態壓縮DP
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = (1 << 10); int map[11][1
原创 hdu 3627 Giant For //線段樹
首先以x爲第一關鍵字,y爲第二關鍵字進行排序,離散化 得到一個長度爲num的數組(任何一次查詢對應的點都能在這個數組中找到) 對此進行建樹 比如進行第i次操作 找到其在數組中對應的點pos 那麼pos--->num這裏面的所有點的x值都
原创 POJ 3311 Hie with the Pie //狀態壓縮DP
TSP,可以用狀態壓縮做,記得先用FLOYED處理 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int n; int
原创 hdu 3030 Increasing Speed Limits
就是在一個500000的串裏找除上升子序列的個數 還是比較容易想到DP轉移方程的 dp[i] = sum(dp[j]|j<i&&a[j]<a[i]) dp[i]就是說以i結尾的上升子序列的個數 現在是平方級的算法 找一個上升子序列,很
原创 hdu 3943 K-th Nya Number
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> using namespace std;
原创 hdu 4000 Fruit Ninja
小大中+小中大= ? #include <cstdio> #include <cstring> const int MAXN = 100000 + 1234; const int mod = 100000007; int n; long
原创 poj 1185 炮兵陣地 //狀態壓縮DP
注意只有一行等這些特殊情況 這種狀態壓縮DP還是比較簡單的,這個題是前2行推出下一行的狀態 #include <cstdio> #include <cstring> #include <algorithm> using namespa
原创 zoj 3344 //組合數學那種的DP
import java.io.*; import java.math.*; import java.util.*; /** * * @author acm */ public class Main { public st
原创 hdu 3333 Turing Tree
按右端點排序 #include <cstdio> #include <map> #include <cstring> using namespace std; const int MAXN = 50010; const int MAXM
原创 hdu 3689 Infinite monkey theorem
去年杭州區域賽的一道題目,比較簡單的AC自動機 #include <stdio.h> #include <string.h> const int NODE = 1000; const int CH = 26; int tree[NODE
原创 poj 3254 Corn Fields //狀態壓縮DP
#include <cstdio> #include <cstring> const int MAXN = (1 << 12) - 1; const int MOD = 100000000; int n, m; int state[1
原创 hdu 3625 Examining the Rooms //組合數學DP
做的十分順利,1Y #include <cstdio> #include <cstring> long long dp[21][21]; double ans[21][21]; double out[21][21]; long long
原创 zju 3526 Weekend Party
每次浙大月賽都打醬油,中午這種題,愣是把數字敲錯了。 。。。。。。 #include <cstdio> #include <cstring> int num[10]; char s[20], s2[10]; int t[10]; i
原创 hdu 3478 //判聯通+二分圖判定
#include<stdio.h> #include<string.h> const int N = 100010; struct NODE { int v, next; }edge[510000 * 2]; int clr[