【URAL 1519】Formula 1】的更多相关文章

http://acm.timus.ru/problem.aspx?space=1&num=1519 调了好久啊.参考(抄)的iwtwiioi的题解. 如果想要题解,题解在<基于连通性状态压缩的动态规划问题>. 我肯定讲得不如题解清楚QAQ,所以还是不讲了(╯‵□′)╯︵┻━┻ 连通性状压得用bfs扩展同时hash表判重.为什么呢? 因为状态太多数组存不下,只能用hash表存有用的状态,没错就是这样!!! 感觉代码量比普通状压高了不少QAQ 这么复杂,还是典型例题→_→. 时间复杂度\(…
插头DP 本题为CDQ<基于连通性状态压缩的动态规划的……(我忘了)>里的例题!(嗯就是这样……) 先膜拜一下ccy大神……http://blog.sina.com.cn/s/blog_51cea4040100gmky.html 在这里将我当初看插头DP的一些不解之处写出来,给大家提供一些参考: 以前我老是搞不懂“左/右插头”的区分……今天终于搞明白了:左插头是一个联通块与轮廓线的左边的交点,右插头是靠右的交点……这下那些分情况讨论的状态转移瞬间就明白了= = 然后是状态表示……其实以前用状压…
[题目链接]:http://hihocoder.com/problemset/problem/1519?sid=1098756 [题意] Chinese [题解] bfs题; 根据bfs的性质; 第一次到达的点肯定是转弯次数最少的; 每次往一个方向走到头就好了; 搞个数组判判重. 这里在往一个方向走的时候; 如果途中遇到了终点; 也算能到达终点; 其他的就没什么坑点了; [Number Of WA] 3 [完整代码] #include <bits/stdc++.h> using namespa…
http://vjudge.net/problem/17662 loli蜜汁(面向高一)树形dp水题 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct nodeTreeDP { struct node {int nxt, to, w;} E[203]; int n, q, cnt, point[103], apple[103], left[103], ri…
题意:求给定字符矩阵中相同正方形矩阵的最大边长和这两个相同正方形的位置 第一次写字符串哈希,选两个不同的模数进行二维字符串哈希. 本来应该取模判断相等后再暴力扫矩阵来判断,但是我看到<Hash在信息学竞赛中的一类应用>中这么写道: 于是我还会再次判重吗?肯定不会!!! 于是这样写完后就调啊调,调出几个像没用unsigned long long这样的脑残错误后交上去就A了233 #include<cstdio> #include<cstring> #include<…
模板题,,,模板打错查了1h+QAQ #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 1000003; int t1[N], t2[N], c[N], f[N][30]; void st(int *x, int *y, int *sa, int n, int m) { int i; for(i =…
题目 #include<cstdio> #include<algorithm> using namespace std; #define N 1005 int n, m, cnt; int a[N], b[N], dp[N]; //dp[i]表示到a[i]大的怪物都死最少要多少个spell int main() { scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) { scanf(&quo…
Description During a discussion of problems at the Petrozavodsk Training Camp, Vova and Sasha argued about who of them could in 300 minutes find a pair of equal squares of the maximal size in a matrix of size N × M containing lowercase English letter…
Description You have a string and queries of two types: replace i'th character of the string by character a; check if substring sj...sk is a palindrome. Input The first line contains a string consisting of n small English letters. The second line con…
[BZOJ1814]Ural 1519 Formula 1 (插头dp) 题面 BZOJ Vjudge 题解 戳这里 上面那个链接里面写的非常好啦. 然后说几个点吧. 首先是关于为什么只需要考虑三进制状态,因为哈密顿回路是不可能出现自交的,因此对于当前的轮廓线一定直接分割了哈密顿回路的一部分,不可能出现只考虑分割出来的情况下,存在插头的连通性直接交叉,否则一定不合法(比如说四个连续位置,你不可能\(1,3\)匹配,因为这样子画一条路径出来,无论如何都会和\(2,4\)的路径相交).因此,我们把一…