# 叉姐200题

PublicTransitHard http://community.topcoder.com/stat?c=problem_statement&pm=13797

BichromeSky http://community.topcoder.com/stat?c=problem_statement&pm=13711
n个红点，m个蓝点，没有三点共线，第i个红点以p_i的概率出现，求红点的凸包包含所有蓝点的概率
n, m <= 100

SimilarSequencesAnother http://community.topcoder.com/stat?c=problem_statement&pm=12742
(A, B) 是相似的，当且仅当A, B各删不超过2个字符后相等。给定长度n和字符集m，问相似(A, B)数量。
n <= 100

TaroCheckers http://community.topcoder.com/stat?c=problem_statement&pm=12996
n * m的棋盘，第i行前l[i]个格子有一个棋子，后r[i]个格子有一个棋子，每列最多有一个棋子，问方案数。
n <= 50, m <= 200

OneDimensionalRobot http://community.topcoder.com/stat?c=problem_statement&pm=12999

AlienAndPermutation http://community.topcoder.com/stat?c=problem_statement&pm=12949

Perfect Matching http://www.spoj.com/problems/MATCH/
n个点的二分图，假设完备匹配的数量是x，判断x = 0 (mod 2)
n <= 300

(False) Face https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=360&page=show_problem&problem=2625
n个点的二分图，假设完备匹配的数量是x，判断x = 0 (mod 4)
n <= 300

Little Elephant and Broken Sorting http://codeforces.com/contest/258/problem/D

n, m <= 1000

Inversions problem http://codeforces.com/problemset/problem/513/G3

n <= 300, m <= 10^9

# Cliquers [PA 2008, Round 5]

n$n$个点有标号的无向图的数量，要求每个连通分量都是团。
n200000$n \leq 200000$

# Isomorphism [SGU 282]

n$n$个点的完全图m$m$染色，问同构意义下有多少种染色方案。
n53,m1000$n \leq 53, m \leq 1000$

# Writing n as the product of k distinct positive integers [PE 495]

n!$n!$写成k$k$个不同的数的乘积的方案数。
n104,k30$n \leq 10^4, k \leq 30$

# Partition [HDOJ 4651]

n$n$的拆分数pn$p_n$
n105$n \leq 10^5$

n=1(1xn)=k=0xk(3k±1)2

# Integer Partition [HDOJ 4658]

n$n$的拆分数，要求数字出现不超过k$k$次。
kn105$k \leq n \leq 10^5$

# Chocolate triangles

n$n$边型剖分中恰好有k$k$个三角形的方案数。
n,k300$n, k \leq 300$

# SWERC 2014 Problem H Money Transfers

n,m1000$n, m \leq 1000$

# CERC 2014 Problem F Vocabulary

|A|,|B|,|C|106$|A|, |B|, |C| \leq 10^6$

# CERC 2014 Problem E Can’t stop playing

n1000,2a1+2a2++2an213$n \leq 1000, 2^{a_1} + 2^{a_2} + \dots + 2^{a_n} \leq 2^13$

# CERC 2014 Problem L Outer space invader

n$n$个怪物，第i$i$个怪物于第ai$a_i$秒出现，第bi$b_i$秒消失，高度是di$d_i$。你可以使用威力是x$x$的炸弹，消灭高度不超过x$x$的所有怪物，代价是x$x$

n300$n \leq 300$

# CERC 2014 Problem J Pork barrel

n1000,m105,q106$n \leq 1000, m \leq 10^5, q \leq 10^6$

# CERC 2014 Problem G Virus synthesis

- 在某端删除一个字符
- 如果S$S$是偶数长度的回文串，删除左半边/右半边

|S|105$|S| \leq 10^5$

# CERC 2014 Problem B Mountainous landscape

n$n$条线段组成的山，对于每条线段，输出站在它上面时，所能看到的第一个顶点
n105$n \leq 10^5$

Subarray Cuts http://codeforces.com/problemset/problem/513/E2

n <= 30000, k <= 200

Permanent http://acdream.info/problem?pid=1027
A是n * n的矩阵，计算perm(A)
n <= 20

Permutation http://acm.hdu.edu.cn/showproblem.php?pid=4917
n个点m条边的有向图，统计拓扑排序的数量
n <= 40, m <= 20

SimilarNames http://community.topcoder.com/stat?c=problem_statement&pm=12868
n个字符串s_1, s_2, …, s_n，m个条件(a_i, b_i)，统计满足s_{p(a_i)}是s_{p(b_i)}前缀的排列p_1, p_2, …, p_n数量
n <= 50, |s_i| <= 50, m <= 8

Permanent http://codeforces.com/problemset/problem/468/E
A是n * n的矩阵，除了给定的k个位置以外都是1，计算perm(A)
n <= 10^5, k <= 50

WinterAndSnowmen Kai!
X, Y \subset {1, 2, …, n}，f({x_1, x_2, …, x_n}= x_1 xor x_2 xor … xor x_n，求f(X) <= f(Y)的方案数
n <= 5000

WinterAndSnowmen http://community.topcoder.com/stat?c=problem_statement&pm=12891
X \subset {1, 2, …, n}, Y \subset {1, 2, …, m}，f({x_1, x_2, …, x_n}= x_1 xor x_2 xor … xor x_n，求f(X) <= f(Y)的方案数
n, m <= 2000

Everlasting L http://acm.hdu.edu.cn/showproblem.php?pid=5116
n * m的有障碍的棋盘，求放2个L的不同方案数，要求L的两边长度互质
n, m <= 200

ThreeLLogo http://community.topcoder.com/stat?c=problem_statement&pm=13059
n * m的有障碍的棋盘，求放3个L的不同方案数
n, m <= 30

FencingPenguins http://community.topcoder.com/stat?c=problem_statement&pm=12339

1. 围栏不能相交
2. 每个围栏至少包含1个企鹅
3. 企鹅都被包围
4. 同色企鹅在同一围栏

N <= 222, M <= 50

An easy problem about trees http://codeforces.com/problemset/problem/457/F

Tree and Table http://codeforces.com/problemset/problem/251/E

Buy One, Get One Free http://codeforces.com/problemset/problem/335/F

Triangles 3000 http://codeforces.com/problemset/problem/528/E
3k条直线，等概率挑选3条，求围成三角形面积的期望

Fox and Meteor Shower http://codeforces.com/problemset/problem/388/E
1k条3维直线，求最大的两两相交的子集

Gena and Second Distance http://codeforces.com/problemset/problem/442/E
1k个点，求次近的点最远的点

Drawing Circles is Fun http://codeforces.com/problemset/problem/372/E

- add(a, b, v) for all a <= i <= b, A[i] += v
- query(a, b) 求#{i : a <= i <= b and A[i] > 0}

Codeforces 15E Holes

- parent[v] := p，保证p > v
- 询问点v的深度
n,q<=105$n, q <= 10^5$

Codeforces 348C
n$n$个元素，m$m$个集合S1,S2,,Sm$S_1, S_2, …, S_m$q$q$次操作：
- 把集合Si$S_i$的元素权值+= v
- 询问集合Si$S_i$元素的权值和
n,|S1|+|S2|++|Sm|,q<=105$n, |S_1| + |S_2| + … + |S_m|, q <= 10^5$

Chengdu 2012 Problem D / HDOJ 4467
n$n$个点m$m$条边的无向图，点有2种颜色，边有权值，q$q$次操作：
- 改变点v$v$的颜色
- 查询端点颜色是(a,b)$(a, b)$的边权值之和
n,m,q<=105$n, m, q <= 10^5$

Chengdu 2013 Problem G / HDOJ 4787
* 在线 * 维护字符串集合S$S$q$q$次操作：
- 在S$S$中插入s$s$
- 查询t$t$S$S$中的子串数
s$s$总长105$10^5$t$t$总长5106$5 * 10^6$
(2~3 solutions will be presented)

SPOJ UNTITLE1

- add(a, b, v) for all a <= i <= b, A[i] += v
- query(a, b) 求max{S[i] : a <= i <= b}，其中S[i] = A[1] + A[2] + … + A[i]
|A|,q<=50000$|A|, q <= 50000$

BZOJ 2724

(an elegant algorithm to count occurrence)

BZOJ 2741

BZOJ 巧克力王国

Codechef March14 GERALD07

Codeforces 19E

SPOJ COT2

(2 solutions will be presented)

SPOJ COT3 Combat on a tree

SPOJ RECTANGL Rectangles

POJ 3145 Harmony Forever

POJ 1741 Tree

SPOJ FTOUR2

HDU 4812 / Nanjing 2013 K

TYVJ 1953

WC 2010 重建计划

Codeforces 150E

Codeforces 193E

SPOJ QTREE4

Codeforces 342E

SPOJ QTREE5

SPOJ QTREE

Codeforces 117E

BZOJ 3083

BZOJ 2049 / SDOI 2008

（LCT or ETT）

SPOJ OTOCI

Topcoder Open 2013 Round 2A ThePowers

A, B <= 10^9

SGU 550 Tree Queries Online

HDU 4621 Life Game
N * M的点阵，对于点(i, j)，将其指定为A类型有A(i, j)的收益，指定为B类型有B(i, j)的收益。R个要求，如果矩形(L_i, D_i) — (R_i, U_i)全是A（或全是B），则获得W_i的收益，问最大收益。
N, M <= 50, R <= 50000

HDU 4673 Pirate’s Chest
N个箱子，对于i号箱子，要么使用A_i号钥匙打开，要么使用B_i号撬棍打开，要么付出D_i点血打开。
M层的塔，每一层塔有入口，怪物，至多两个工具，且一定同类型，可以在任意地点上下楼。

N <= 30000, M <= 1000

HDU 4679 Terrorist’s destroy
N个点的树，删除一条边，使得边权和剩下的树的直径乘积最小。
N <= 10^5

HDU 4689 Derangement

N <= 1000

Single Round Match 565 UnknownTree
N + 3个点的树，给出disA[i], disB[i], disC[i]表示1 <= i <= N号点到A, B, C的距离，求可能的树的方案数。
N <= 50

Single Round Match 561 Orienteering
N个点的树，随机选择K个点，问遍历K个点最短路径的期望。
K <= N <= 300

SCOI 2013 数数

1 <= L <= R < B^100000, B <= 10^5

Codeforces 273D Dima and Figure
N * M的点阵，问凸的点集的数量，mod (10^9 + 7)。
(N, M <= 150)

Codeforces 375E Red and Black Tree
N个点的树。点有黑、白2种颜色。任意交换点的颜色，使得对于任一个点，距离它D以内都至少有一个黑点，求最少的交换次数。
N <= 500

Codeforces 392E Deleting Substrings

- |x_{i + 1} - x_i| = 1，
- 2 x_i >= x_{i - 1} + x_{i + 1}，

N <= 400

NEERC Eastern Subregional Contest 2013 Problem C CVS

1. learn(i, j)
2. rollback(i)
3. relearn(i)
4. clone(i)
5. check(i)
Q <= 10^5

NEERC Northern Subregional Contest 2013 Problem L Lonely Mountain

JAG Summer 2012 Problem G Presentation

Single Round Match 570 CurvyonRails

M * M棋盘上有N个有缺陷的皇后（只能攻击主对角线），求被至少1个皇后攻击的格子数量。
N, M <= 10^5

|P|, |T| <= 10^5，|Sigma| <= 10

|P|, |T| <= 10^5

N <= 130000
O(N log^2 N)

A_i <= 10^6

(FWT)
Topcoder Open 2012 Round 2A EvenPaths
N个点的有向无环图，K个点可能有障碍。

N <= 50, K <= 32

HDOJ 4656 Evaluation

N <= 10^5, A_i, B, C, D <= 10^6

SPOJ MOD Power Modulo Inverted

A, B, M <= 10^9

Petrozavodsk Summer 2011 Kyiv + Kharkiv NU Contest Problem A A Lot

P <= 10^8, Q <= 10^4

Project Euler 457 A polynomial modulo the square of a prime

N <= 10^7

Codeforces 193E Fibonacci Number

F < 10^13

Petrozavodsk Winter 2008 Warsaw Contest Problem J Sum of a subsequence

N = 10^k，k <= 5

Codeforces 62E World Evil
n * m的点阵，如下图，求左边到右边的最大流。
n <= 5, m <= 10^5

Single Round Match 608 BigO
N个点的有向图，假设在上面走x步的方案数是O(x^K)的，求K的最小值。
N <= 50

Single Round Match 607 CombinationLockDiv1

|A|, |B| <= 50

Single Round Match 592 LittleElephantAndPermutationDiv1

N <= 50, K <= 2500

Single Round Match 588 KeyDungeonDiv1
N个房间，每个房间需要doorRed[i]把红钥匙，doorGreen[i]把绿钥匙，房间里面有roomRed[i], roomGreen[i], roomWhite[i]把红、绿、白钥匙。白钥匙可以作为红、蓝钥匙使用。初始有keys[]把三种钥匙，打开一些房间，问手上最多的钥匙数。
N <= 12, 钥匙数 <= 10

Single Round Match 582 ColorfulBuilding
N个矩形，第i个矩形的高度是i，颜色是color[i]，问所有排列中从左到右能看到K次颜色变化的数量。
K <= N <= 36 * 36

Single Round Match 577 EllysChessboard
8 * 8的棋盘上，在指定位置放棋子，放棋子的代价是到曼哈顿距离最远的棋子距离，问最小的总代价。

Topcoder Open 2012 Round 3B ElevenMultiples
N个10进制数字片段P_1, P_2, …, P_n，问有多少种方法使得连接之后是11的倍数。
N <= 50

Single Round Match 601 WinterAndShopping
N个商店卖球。第i个商店在第first[i]天开业，有red[i]个红球，green[i]个绿球，blue[i]个蓝球。商店每天卖1个球，所有商店卖的球颜色相同。同时营业的商店不超过2个。求方案数。
N <= 50，red[i], green[i], blue[i] <= 100，first[i] + red[i] + green[i] + blue[i] <= 500

Single Round Match 594 FoxAndAvatar
1, 2, …, N以行为主序排列在宽度是W的矩阵上。每次可以删除一个子矩形中的所有数字，并重新排列剩余数字。问最后留下数字X的最小操作次数。
W <= N <= 3000

Single Round Match 593 WolfDelaymasterHard

N <= 2 * 10^6

Single Round Match 591 StringPath

N, M <= 8

Single Round Match 589 FlippingBitsDiv1

1. 翻转某位
2. 翻转长度k * M的前缀(k >= 1)

N <= 300

Single Round Match 583 RandomPaintingOnABoard
N * M的矩阵P，每次以P[i][j] / sum{P[i][j]}的概率选择格子(i, j)，问每行每列都被选择至少一次所需要的步数期望。
N, M <= 21, N * M <= 150, P[i][j] < 10

Topcoder Open 2013 Round 3A TrickyInequality
M个整数变量x_1, x_2, …, x_M满足：
1. x_1, x_2, …, x_M >= 1
2. x_1 + x_2 + … + x_M <= S
3. x_1, x_2, …, x_N <= T

M <= 10^9, M - N <= 100, T <= 10^5, N * T <= S

Single Round Match 578 DeerInZooDivOne
n个点的树，求两颗不相交的子树，它们同构同时大小最大。
n <= 50

Single Round Match 573 WolfPack

M <= 100000

Single Round Match 569 MegaFactorial

1. f(n, k) = f(n - 1, k) * f(n, k - 1)
2. f(0, k) = 1
3. f(n, 0) = n

N <= 10^9, K <= 16, B <= 10

Single Round Match 562 InducedSubgraphs
N个点的树，问有多少种标号方式，使得对所有1 <= i <= N - K + 1，点集{i, i + 1, …, i + K- 1}是连通的。
N <= 40

Single Round Match 560 BoundedOptimization
N个变量x_i，满足L_i <= x_i <= R_i，且X_1 + X_2 + … + X_n <= S，求一个特殊二次式的最大值（无平方项，无一次项，系数都是1）。
N <= 13

Single Round Match 550 ConversionMachine

|A|, |B| <= 11

POJ 2793 / NEERC 2005

IOI 2008 Islands

POJ 3567 / NEERC 2007

POJ 3961 / NEERC 2010

Codeforces 379G

Project Euler 416 A frog’s trip
N个格子，一只青蛙1 -> N -> 1，重复M次。

N <= 10^12, M <= 10

P = 51061, N < P^10

SRM 518 Nim

1. x_i是质数
2. x_i <= L
3. x_1 xor x_2 xor … xor x_K = 0
K <= 10^9, L <= 5 * 10^4

Topcoder Open 2012 Round 2B SequenceTransmission

A <= 40000，B <= 10^18, N <= 10^12

Project Euler 439 Sum of sum of divisors

N <= 10^11

SPOJ LCMSUM

N <= 1000000, 300000组数据

N, M <= 10^7

N <= 10^9, A, B <= 3000

POI X Trinomial

SRM 536 BinaryPolynomialDivOne

deg P < 50, M <= 10^18

Topcoder Open 2012 Round 3A CowsMooing
N头牛，第i头牛按照pattern_i moo，求count[i]表示50!内恰好有i头牛moo的时间，答案模109+7$10^9+7$
N <= 30, |pattern_i| <= 50

BOI 2010 Candy

n <= 100
1 <= a_i <= 7000

SRM 478 RandomApple
n个盒子，m种苹果，第i个盒子里第j种苹果的数量是A(i, j)。

n, m <= 50, 0 <= A(i, j) < 200

SPOJ LIS2

x_{i_1} < x_{i_2} < … < x_{i_k}
y_{i_1} < y_{i_2} < … < y_{i_k}，求k的最大值。
n <= 10^5

SRM 610 MiningGoldHard

?
?

n <= 1000
A, B <= 10^6

IOI 2004 Hermes

n <= 2000, |x_i|, |y_i| <= 1000

IOI 2002 Batch Scheduling
n个任务顺序执行，第i个任务所需时间time[i]，权重是weight[i]。

n <= 10000

POI XIII Frogs (Simplified)
n * m的棋盘，k个障碍，对于每个点，求其欧几里得距离最近的障碍。
n, m <= 1000

World Finals 2011 Machine Works

n <= 100000

PA 2009 Drilling

n <= 2000

Codeforces 321E
n个人顺序分成k组，使同组人之间的陌生度之和最小。
n <= 4000, k <= 800

SRM 478 KiwiJuice
n个杯子，容量是c，初始的水量是c_1, c_2, …, c_n。可以互相倒水，每次只能在空或满时停止。卖掉一个水量是x的杯子获得value[x]元，问最多获得的钱数。
n <= 15

SPOJ TLE

?
?
?
n <= 50, m <= 15

SGU 327 Yet Another Palindrome
n个字符串s_1, s_2, …, s_n，找包含它们作为子串的最短回文串。
n <= 14, |s_i| <= 30

Codeforces 86C Genetic engineering
m个模板串s_1, s_2, …, s_m，求长度为n的序列，使得能被完全覆盖。
m <= 10, |s_i| <= 10, n <= 1000, s_i in {A, C, T, G}^+

Codeforces 55D Beautiful numbers

L, R <= 9 * 10^18

SGU 258 Almost Lucky Numbers

L, R <= 10^9

SGU 390 Tickets

L, R <= 10^18, K <= 1000

SPOJ ININT

n <= 10^9

POI XVII Crystals

?
?
?

SGU 542 Gena vs Petya

n <= 2 * 10^5, a_i <= 10^18

http://main.edu.pl/en/archive/oi/13/tan

Project Euler 355 Maximal coprime subset

N <= 200000

Project Euler 452 Long Products

N, M <= 10^9

Winter Camp 2012 糖果公园

SGU 529 It’s Time to Repair the Roads

Tsinsen 1321 Attack (Chao Li)
2维平面上n$n$个点，支持q$q$次操作：
- 修改点权
- 询问平行于坐标轴的矩形区域内点权第k$k$小的值
n<=60000,q<=10000$n <= 60000, q <= 10000$

k$k$-th number with insertion

PA 2011 Kangaroos

n<=50000,m<=200000$n <= 50000, m <= 200000$

CTSC 2010 jewelry

Knapsack [Unpublished problem]
n$n$个数A1,A2,,An$A_1, A_2, …, A_n$，对于所有s$s$，求和恰好是s$s$的子集个数。
(n,A1+A2++An<=105$n, A_1 + A_2 + … + A_n <= 10^5$)

Codeforces 235E Number Challenge

A, B, C <= 2000

HDU 4626 Jinkeloid

|S| <= 10^5, Q <= 10^5，|Sigma| <= 20, C_i <= 5

Single Round Match 596 BitwiseAnd

- 任意x, y in S, x & y > 0
- 任意x, y, z in S, x & y & z = 0

Single Round Match 596 SparseFactorial

L, R <= 10^12，D <= 10^6

PQHull

Chengdu 2012 Problem J / HDOJ 4473

n<=1011$n <= 10^11$

Project Euler 379

n=1012$n = 10^12$

POI XIV Queries
n$n$个询问形如(a,b,d)$(a, b, d)$，统计满足1<=x<=a,1<=y<=b$1 <= x <= a, 1 <= y <= b$gcd(x,y)=d$gcd(x, y) = d$(x,y)$(x, y)$
n,a,b,d<=50000$n, a, b, d <= 50000$

SPOJ PGCD
t$t$个询问形如(n,m)$(n, m)$，统计满足1<=x<=n,1<=y<=m$1 <= x <= n, 1 <= y <= m$gcd(x,y)$gcd(x, y)$是质数的(x,y)$(x, y)$
t<=10,n,m<=107$t <= 10, n, m <= 10^7$

Hangzhou 2013 Online / HDOJ 4746

q$q$个询问形如(n,m,k)$(n, m, k)$，统计满足1<=x<=n,1<=y<=m$1 <= x <= n, 1 <= y <= m$p(gcd(x,y))<=k$p(gcd(x, y)) <= k$(x,y)$(x, y)$
q<=5000,n,m,k<=5105$q <= 5000, n, m, k <= 5 * 10^5$

Project Euler 388

n=1010$n = 10^10$

Project Euler 402 Integer-valued polynomial

S(n)=0<a,b,cnM(a,b,c)$S(n) = \sum_{0 < a, b, c \leq n} M(a, b, c)$
sum2<=k<=KS(fibk)mod109$sum_{2 <= k <= K} S(fib_k) \bmod 10^9$

TCO 2013 2B LitPanels
nm$n * m$的矩形，把若干格子点亮，要求点亮的格子能被2$2$ab$a * b$的覆盖，求方案数。

Project Euler 453
n×m$n \times m$的点阵，统计非退化的四边形数量，答案mod 135707531。

SRM 600 LotsOfLines

A,B<=1200$A, B <= 1200$

HDOJ 4609

n,Ai<=105$n, A_i <= 10^5$

SRM 603 SumOfArrays

1<=n<=105,0<=A[i],B[i]<=105$1 <= n <= 10^5, 0 <= A[i], B[i] <= 10^5$ 数据随机

HDOJ 4624

n<=50000,k<=500$n <= 50000, k <= 500$

HDOJ 4624
n$n$个白球，每次随机段区间染黑，问染成全黑的期望次数。
n<=50$n <= 50$

n<=1014$n <= 10^14$

01-19 1564

05-31 446

02-21 1006

10-01 2989

#### 数据结构讲义-叉姐(交大郭晓旭)

2015年08月12日 450KB 下载

01-02 249

11-04 1288

05-22 272

06-03 40

05-27 42