复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int nt_max = 50 + 5;
int n, t, cnt;
char Queue[nt_max];
int main()
{
while(~scanf("%d %d", & n, & t))
{
scanf("%s", Queue);
while(t --)
{
for(int i = 0; i < n; )
{
if(Queue[i] == 'B')
{
if(Queue[i + 1] == 'G')
{
Queue[i] = 'G';
Queue[i + 1] = 'B';
i += 2;
}
else
i ++;
}
else
i ++;
}
}
printf("%sn", Queue);
}
return 0;
}
题目:
就是在学校 男女生排队。男生比较傻比,一定要给女生排在前面。输入n 表示 总人数, 输入 t 表示 移动的时间。问t分钟后 队列最后的排列。(每个人一分钟交换一次位置)
题解:
2个月前 误会了这道题的意思,今天拿出来做,还是弄错了意思。一分钟交换一个位置,如果在当前时间BBG,过一分钟只会 BGB,不会GBB(只交换一次)。模拟过程即可。
最后
以上就是朴实冬天最近收集整理的关于CodeForces-266B Queue at the School的全部内容,更多相关CodeForces-266B内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复