Codeforces D. Sorting the Coins】的更多相关文章

D. Sorting the Coins time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite o…
题意:有n个数的序列,n个数都为0,每次指定某个数变为1,当序列中第i个数为1,第i+1个数为0时,这两个数可交换,将序列从头到尾进行一次交换记为1次,直到某一次从头到尾的交换中没有任何两个数交换.序列的hard值为进行前面叙述过程中共进行的从头到尾交换的次数.每修改某个数为1,都输出对应的hard值. 分析: 1.如果第一次将最后一个数变为1,显然验证交换的次数为1,这一趟验证了没有任何两个数需要交换,因此结束. 2.如果第一次将中间的某个数变为1,显然我们在第一次从头到尾的交换中可以把这个1…
http://codeforces.com/contest/876/problem/D D. Sorting the Coins time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Recently, Dima met with Sasha in a philatelic store, and since then they are…
http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的"O"变为"X",之后会进行扫描. 扫描的规则是如果遇到一个字符为"X"并且这个字符后面的字符为"O",那么就交换. 如果哪一次扫描没有发生交换,那么扫描就停止. 现在给出的n个数字,问第一次需要扫描多少次,第二次需要扫描多少次....…
http://codeforces.com/contest/876/problem/D 题意:题意真是难懂,就是给一串序列,第i次操作会在p[x](1<=x<=i)这些位置放上硬币,然后从左到右观察,如果第i个位置有硬币但第i+1个位置没有硬币,那么互换,然后继续从第i+1个硬币开始看.直到不需要交换,需要计算出到终极状态需要多少步. 思路: 模拟. #include<iostream> #include<algorithm> #include<cstring&g…
题目链接:http://codeforces.com/contest/876/problem/D 题解:一道简单的类似模拟的题目.其实就是看右边连出来有多少连续不需要换的假设位置为pos只要找pos-1左边一共有多少x就行(x是什么看一下样例) 第一个是正常解法第二个是用线段树写的,其实正常写就是模拟一下就好 #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #i…
Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a…
Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 0…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned…
早起一水…… 题意看着和蓝桥杯B组的大题第二道貌似一个意思…… 不过还是有亮瞎双眼的超短代码…… 总的意思呢…… 就是最长增长子序列且增长差距为1的的…… 然后n-最大长度…… 这都怎么想的…… 希望今天的省选可以亮光乍现~~~ #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> using namespace s…