Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
来源:互联网 发布:视频图像分析算法 编辑:程序博客网 时间:2024/05/17 22:51
要维护区间内字符数为定值,求最小的满足条件的区间典型的双指针。
#include <cstdio>#include <iostream>#include <cstring>#include <set>#include <map>using namespace std;#define pr(x) cout << #x << ": " << x << " " #define pl(x) cout << #x << ": " << x << endl;struct jibancanyang{ int n, t; string str; void two() { int l = 0, r = 0; map<char, int> st; int ret = int(1e9); while (l < n) { while (r < n && (int)st.size() < t) { st[str[r++]]++; } if (t <= (int)st.size()) ret = min(ret, r - l); else break; st[str[l]]--; if (st[str[l]] == 0) st.erase(str[l]); l++; } cout << ret << endl; } void run() { cin >> n >> str; set<char> st; for (int i = 0; i < (int)str.size(); i++) { st.insert(str[i]); } t = st.size(); two(); }}ac;int main(){#ifdef LOCAL freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);#endif ac.run(); return 0;}
0 0
- Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
- Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
- Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
- CF #364 (Div. 2)(C. They Are Everywhere 尺取法)
- Codeforces Round #364 div.2 C. They Are Everywhere 【尺追法】
- Codeforces Round #364 (Div. 2) C. They Are Everywhere(二分)
- Codeforces Round #364 (Div. 2)C. They Are Everywhere
- Codeforces Round #364 (Div. 2) C. They Are Everywhere
- 【CodeForces】701C - They Are Everywhere(尺取法)
- 【Codeforces】-701C-They Are Everywhere(尺取法)
- CodeForces 701C They Are Everywhere (尺取法)
- Codeforces #364(Div.2)C.They Are Everywhere【思维】
- Codeforces Round #364 C. They Are Everywhere分析及题解 尺取法
- Codeforces Round #364 (Div. 2) C They Are Everywhere(滑窗)
- Codeforces Round #364 (Div. 2) C. They Are Everywhere (窗口滑动)
- Codeforces Round #364 (Div. 2) C. They Are Everywhere(stl+乱搞)
- Codeforces Round #364 (Div. 2) C. They Are Everywhere __ two pointers or binary search
- codeforces 701C They Are Everywhere(尺取法)
- VS2010 MPI并行环境设置
- [树形dp] poj 2486 Apple Tree
- mysql修改root密码
- 2016 Multi-University Training Contest 1 1005 Necklace (hdu5727)【枚举+匹配】
- C - C
- Codeforces Round #364 (Div. 2) C. They Are Everywhere (尺取法)
- oracle expdp impdp总结
- Eclipse中实现Tomcat热部署
- 多线程题目
- 持续化
- android系统各种音量的获取与设置
- <设计模式2>抽象工厂模式
- 前端校验
- JS alert() 弹出框乱码的问题