码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces - 864B Polycarp and Letters

时间:2017-09-30 17:42:40      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:scan   mes   font   pac   include   log   set   位置   eps   

题意:已知长度为n的字符串,求最大的位置集合,使集合内的每个位置所对应的都是小写字母且各不相同,而且相邻位置间无大写字母。

#include<bits/stdc++.h>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 200 + 10;
const int MAXT = 500 + 10;
using namespace std;
char s[MAXN];
set<char> st;
int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] >= ‘A‘ && s[i] <= ‘Z‘){
            ans = max(ans, (int)st.size());
            st.clear();
        }
        else{
            st.insert(s[i]);
        }
    }
    ans = max(ans, (int)st.size());
    printf("%d\n", ans);
    return 0;
}

  

CodeForces - 864B Polycarp and Letters

标签:scan   mes   font   pac   include   log   set   位置   eps   

原文地址:http://www.cnblogs.com/tyty-Somnuspoppy/p/7615453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!