• 【CF1025A】Doggo Recoloring(签到)


    题意:给定一个长度为 n 的小写字母串。可以将出现次数大于等于2的字母全部变成另一个小写字母,问最后能否将该小写字母串的所有字母变成同一个字母

    n<=1e5

    思路:

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<string>
     4 #include<cmath>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<map>
     8 #include<set>
     9 #include<queue>
    10 #include<vector>
    11 using namespace std;
    12 typedef long long ll;
    13 typedef unsigned int uint;
    14 typedef unsigned long long ull;
    15 typedef pair<int,int> PII;
    16 typedef vector<int> VI;
    17 #define fi first
    18 #define se second 
    19 #define MP make_pair
    20 #define N   1100000
    21 #define MOD 1000000007
    22 #define eps 1e-8 
    23 #define pi acos(-1)
    24 #define oo 110000000000000
    25 
    26 char a[N];
    27 int b[N],c[N];
    28 
    29 
    30 int read()
    31 { 
    32    int v=0,f=1;
    33    char c=getchar();
    34    while(c<48||57<c) {if(c=='-') f=-1; c=getchar();}
    35    while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
    36    return v*f;
    37 }
    38 
    39 
    40 void swap(int &x,int &y)
    41 {
    42     int t=x;x=y;y=t;
    43 }
    44 
    45 
    46 
    47 int main()
    48 {
    49     //freopen("1.in","r",stdin);
    50     //freopen("1.out","w",stdout);
    51     int n;
    52     scanf("%d",&n); 
    53     scanf("%s",a+1);
    54     for(int i=1;i<=n;i++) b[a[i]-'a'+1]++;
    55     if(n==1) printf("Yes
    ");
    56      else
    57      {
    58          int flag=0;
    59          for(int i=1;i<=26;i++)
    60           if(b[i]>=2) flag=1;
    61          if(flag) printf("Yes
    ");
    62           else printf("No
    ");
    63      }
    64     return 0;
    65 }
  • 相关阅读:
    hdu 2680(最短路)
    hdu 1548(最短路)
    hdu 1596(最短路变形)
    hdu 1546(dijkstra)
    hdu 3790(SPFA)
    hdu 2544(SPFA)
    CodeForces 597B Restaurant
    CodeForces 597A Divisibility
    CodeForces 598E Chocolate Bar
    CodeForces 598D Igor In the Museum
  • 原文地址:https://www.cnblogs.com/myx12345/p/9843966.html
Copyright © 2020-2023  润新知