当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

BZOJ4045:[Cerc2014] bricks

题目描述
You are given a sequence of white (W) and black (B) bricks. The goal is to partition it into 
some number of non-empty, contiguous blocks, each one having the same ratio of white and black 
bricks. 
Of course one can always "partition'7 the sequence into one single block (which is not very 
interesting). We want, however, to have as manv blocks as possible. Consider for example the 
following sequences and its partitions: 
●BWWWBB 
BW + WWBB (rati0 1:1) 
~ WWWBBBWWWWWWWWWB 
WWWB + BBWWWWWW + WWWB (rati0 3:1) 
Note that both of these partitions are optimal with respect to the number of blocks 

输入解释
The first line of input contains the number of test cases T. The descriptions of the test cases 
follow: 
Each test case starts with one line containing an integer n (1《 n≤ 105) which is the length of 
the description of a sequence. Each of the following n lines consists of an integer k (1≤ k < 10^9) 
and one of the characters W or B, meaning that k bricks of the given color follow next in the 
sequence. It is guaranteed that the total length of the brick sequence does not exceed 10^9. 

输出解释
For each test case, output a single line containing the largest possible number of blocks 
Example

输入样例
3
3
1 B
3 W
2 B
4
3 W
3 B
9 W
1 B
2
2 W
3 W
输出样例
2
3
5
提示

BZPRO Powered by Remmina.
Github Repository
来自acmore.cc的附加信息
bzoj_id 4045
import_source_sha256 ff2bd2de5f9a189ee2766e9ac19905094b25839baa42b576057b03d4571664f6
bzoj_checker_pending False

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 4045

源链接: LOCAL-BZOJ4045

共提交 0 次

通过率 --%
时间上限 内存上限
20000 MS 512 MB