首页 > 代码库 > Codeforces Round #407 (Div. 2)

Codeforces Round #407 (Div. 2)

A 模拟

B 大力分类讨论

  1. |b1|?>?l — answer is 0.
  2. b1?=?0 — if 0 is present in array a than answer is 0, else inf.
  3. q?=?1 — if b1 is present in array a than answer is 0, else inf.
  4. q?=??-?1 — if both b1 and ?-?b1 are present in array a than answer is 0, otherwise inf.
  5. 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.
  6. 直接暴力判

或者是取巧的方法,观察到如果可能出现循环,由于循环节<=2,答案只能是0,1,inf.

//其实也要讨论,只不过代码变短了许多

C 枚举结尾的位置,类dp一波 //f[i] = 以i为头的子串最大权值

Codeforces Round #407 (Div. 2)