zoukankan      html  css  js  c++  java
  • Codeforces Round #434 C

    Did you mean...

    题意:a e i o u是元音,在一个字符串里不能有3个连续的辅音,但是3个及以上相同的连续辅音可以,否则就要用空格隔开,给你字符串,用最少的空格把字符串变为合法

    思路:模拟就是了

    AC代码:

    #include "iostream"
    #include "iomanip"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a,x) memset(a,x,sizeof(a))
    #define step(x) fixed<< setprecision(x)<<
    #define mp(x,y) make_pair(x,y)
    #define pb(x) push_back(x)
    #define ll long long
    #define endl ("
    ")
    #define ft first
    #define sd second
    #define lrt (rt<<1)
    #define rrt (rt<<1|1)
    using namespace std;
    const ll mod=1e9+7;
    const ll INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const double PI=acos(-1.0);
    const int N=1e5+100;
    
    char s[30005];
    int is[1005],ans[30005];
    
    int main(){
        cin>>s+1;
        is['a']=1, is['e']=1, is['i']=1, is['o']=1, is['u']=1;
        int n=strlen(s+1);
        for(int i=1; i<=n; ++i){
            if(!is[s[i]]){
                int k=0;
                for(int j=i; j<=n; ++j){
                    if(is[s[j]]){
                        i=j;
                        break;
                    }
                    k++;
                    if(k>2){
                        if(s[j] == s[j-1] && s[j-1]==s[j-2]){
                            for(int t=j+1; t<=n; ++t){
                                if(s[t]!=s[t-1]){
                                    if(is[s[t]]){
                                        i=t;
                                        break;
                                    }
                                    ans[t-1]=1;
                                    i=t-1;
                                    break;
                                }
                            }
                        }
                        else{
                            ans[j-1]=1;
                            i=j-1;
                            break;
                        }
                        break;
                    }
                }
            }
        }
        for(int i=1; i<=n; ++i){
            cout<<s[i];
            if(ans[i]) cout<<" ";
        }
        return 0;
    }
  • 相关阅读:
    WannaCry蠕虫分析与预防
    对网络传输的理解
    RESTful API 设计最佳实践
    码农们的密码
    腾讯云公网负载均衡技术实现详解
    ELK统一日志系统的应用
    ElasticSearch + Canal 开发千万级的实时搜索系统
    聊架构:5分钟了解REST架构
    Netty5 HTTP协议栈浅析与实践
    这里,彻底了解HTTPS
  • 原文地址:https://www.cnblogs.com/max88888888/p/7552395.html
Copyright © 2011-2022 走看看