A 模拟
B 大力分类讨论
- |b1|?>?l — answer is 0.
- b1?=?0 — if 0 is present in array a than answer is 0, else inf.
- q?=?1 — if b1 is present in array a than answer is 0, else inf.
- q?=??-?1 — if both b1 and ?-?b1 are present in array a than answer is 0, otherwise inf.
- q?=?0 — if 0 isn‘t present in array a than answer is inf, else if b1 is present in a than answer is 0, else answer is 1.
- 直接暴力判
或者是取巧的方法,观察到如果可能出现循环,由于循环节<=2,答案只能是0,1,inf.
//其实也要讨论,只不过代码变短了许多
C 枚举结尾的位置,类dp一波 //f[i] = 以i为头的子串最大权值
Codeforces Round #407 (Div. 2)
原文:http://www.cnblogs.com/supy/p/6898089.html