目录
一、题目
1、题目描述
2、输入输出
2.1输入
2.2输出
3、原题链接
二、解题报告
1、思路分析
2、复杂度
3、代码详解
一、题目
1、题目描述
2、输入输出
2.1输入
2.2输出
3、原题链接
353D - Queue
二、解题报告
1、思路分析
手玩一下,我们发现相邻的两个女孩,一前一后,如果前面那个能动,那么后面那个是前面那个时间 + 1
然后再看最前面的女生,她的时间取决于她前面有多少男生
所以有了下面的做法:
维护最晚时间res
遍历字符串,记录当前遇到的M的个数c
如果遇到女生,如果c > 0,那么res = std::max(res + 1, c)
即,时间不会比前面男生数目少,不会比前面女生时间+1早
2、复杂度
时间复杂度: O(N)空间复杂度:O(N)
3、代码详解
#include <bits/stdc++.h>
// #define DEBUG
using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
constexpr int inf32 = 1E9 + 7;
constexpr i64 inf64 = 1E18 + 7;
constexpr int P = 1E9 + 7;
void solve(){
	std::string s;
	std::cin >> s;
	int res = 0, m = 0;
	for (char c : s) 
		if (c == 'M')
			++ m;
		else if(m)
			res = std::max(res + 1, m);
	std::cout << res;
}
auto FIO = []{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	return 0;
}();
int main() {
	#ifdef DEBUG
		freopen("in.txt", 'r', stdin);
		freopen("out.txt", 'w', stdout);
	#endif
	int t = 1;
	// std::cin >> t;
	while(t --)
		solve();
	return 0;
} 
                





![[数据集][目标检测]井盖丢失未盖破损检测数据集VOC+YOLO格式2890张5类别](https://i-blog.csdnimg.cn/direct/31cf5cd2f3cd4257a13e5fb30d7908a0.png)















