进度:6/40
我觉得我的思维还是太差了,多练思维题吧!!!!(燃起来
简直是思维题b题专题了,现在连b都做不出了吗(悲
原题1:
Cats are attracted to pspspsps, but Evirir, being a dignified dragon, is only attracted to pspspsps with oddly specific requirements...
Given a string s=s1s2…sns=s1s2…sn of length nn consisting of characters p, s, and . (dot), determine whether a permutation∗∗ pp of length nn exists, such that for all integers ii (1≤i≤n1≤i≤n):
- If sisi is p, then [p1,p2,…,pi][p1,p2,…,pi] forms a permutation (of length ii);
- If sisi is s, then [pi,pi+1,…,pn][pi,pi+1,…,pn] forms a permutation (of length n−i+1n−i+1);
- If sisi is ., then there is no additional restriction.
∗∗A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).
(如果第i位字符为‘p’,则0~i位必须为全排列(如:4的全排列是1,2,3,4以任意顺序组成数组)。如果第i位字符为‘s’,则i~n位必须为全排列。求一个字符串是否能得到全排列)
原题2:
You are given a strip divided into cells, numbered from left to right from 00 to 10181018. Initially, all cells are white.
You can perform the following operation: choose two white cells ii and jj, such that i≠ji≠j and |i−j|≤k|i−j|≤k, and paint them black.
A list aa is given. All cells from this list must be painted black. Additionally, at most one cell that is not in this list can also be painted black. Your task is to determine the minimum value of kk for which this is possible.
(一个白格子的递增数组,a[i]与a[i+1]的距离k可以让二者变成黑格子,最多可以让一个不是数组内的格子变成黑色,求距离k的最小值)
原题1:pspspsps(994.B)
思路:
只有字符串中不存在p或s任意一个,或者唯一的s在第一位,或者唯一的p在最后一位时,能满足需求,后二者是因为唯一的s(或者p)的全排列范围包含了其余p(或者s)的全部的全排列范围。
原题2:Black Cells(edu 171.B)
思路:
调了好久的bug,一度认为自己的做法非常完美,终于还是在看了别人的思路后恍然大悟,我的做法太理想当然了。我认为n为奇数时,只要把与相邻两数的差最大的坐标揪出来就行,但是事实上,揪出不同的坐标,每个点与之配套的点就会发生改变。例如: