当前位置:网站首页>Cf:d. black and white stripe
Cf:d. black and white stripe
2022-06-11 18:47:00 【Review of the white speed Dragon King】

analysis
Every time l and r Forward one
Analyze the elements of the head and tail , To get the minimum number in the current window
Ac code
for t in range(int(input())):
#print(str(t) + ':')
n, k = list(map(int, input().split()))
s = input()
cntW = 0
ans = 0xffffffff
for i in range(k):
if s[i] == 'W':
cntW += 1
ans = min(ans, cntW)
for i in range(k, n):
if s[i] == 'W' and s[i - k] == 'W':
pass
elif s[i] == 'W' and s[i - k] == 'B':
cntW += 1
elif s[i] == 'B' and s[i - k] == 'W':
cntW -= 1
elif s[i] == 'B' and s[i - k] == 'B':
pass
ans = min(ans, cntW)
print(ans)
summary
Thinking Shifts + The sliding window
边栏推荐
- 让我们的坦克欢快的动起来吧
- Signal processing and capture
- Flink CDC 在大健云仓的实践
- cf:A. Print a Pedestal (Codeforces logo?)【简单遍历模拟】
- Download the code and compile the environment
- Swagger2 easy to use
- 非递归实现二叉树的前、中、后序遍历
- Project management of workflow and business service on SAP BTP
- . Net core redis hyperloglog type
- Summary of common mysql/redis interview questions
猜你喜欢
Mysql深入完全学习---阶段1---学习总述

牛客刷题——Fibonacci数列

Niu Ke's question -- Fibonacci series

Labelme for image data annotation

leetcode:剑指 Offer 56 - II. 数组中数字出现的次数 II【简单排序】

2022-2023年西安交通大学管理学院MEM提前批面试网报通知

Quanzhi T3 development board (4-core arm cortex-a7) - detailed explanation of logo display during system startup

「案例分享」基于 AM57x+ Artix-7 FPGA开发板——PRU开发手册详解

基于TI AM5728 + Artix-7 FPGA开发板(DSP+ARM) 5G通信测试手册

全志科技T3開發板(4核ARM Cortex-A7)——MQTT通信協議案例
随机推荐
* Jetpack 笔记 Room 的使用
Deploy a go MSSQL API endpoint on SAP kyma
Niuke's brush question -- judgment of legal bracket sequence
In 2023, the MPAcc of School of management of Xi'an Jiaotong University approved the interview online in advance
On the sequence traversal of binary tree
SA token single sign on SSO mode 2 URL redirection propagation session example
平衡搜索二叉树——AVL树
Ti am64x - the latest 16nm processing platform, designed for industrial gateways and industrial robots
leetcode:926. 将字符串翻转到单调递增【前缀和 + 模拟分析】
牛客刷题——part8
Teach you how to learn the first set and follow set!!!! Hematemesis collection!! Nanny level explanation!!!
Complete in-depth learning of MySQL from 0 to 1 -- phase 2 -- basics
2023年西安交通大学管理学院MPAcc提前批面试网报通知
The US inflation rate reached a 41 year high of 8.6%! High inflation fever? The stock and encryption markets fell first!
开发中必备的文件的上传与下载
cf:C. Restoring the Duration of Tasks【找规律】
Niu Ke's questions -- binary search tree and bidirectional linked list
全志T3开发板(4核ARM Cortex-A7)——系统启动阶段LOGO显示详解
Financial bank_ Introduction to collection system
「案例分享」基于 AM57x+ Artix-7 FPGA开发板——PRU开发手册详解