zoukankan      html  css  js  c++  java
  • Codeforces Round #300 A. Cutting Banner 水题

    A. Cutting Banner

    Time Limit: 1 Sec  Memory Limit: 256 MB

    题目连接

    http://codeforces.com/contest/538/problem/A

    Description

    A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.

    There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.

    Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.

    Input

    The single line of the input contains the word written on the banner. The word only consists of upper-case English letters. The word is non-empty and its length doesn't exceed 100 characters. It is guaranteed that the word isn't word CODEFORCES.

    Output

    Print 'YES', if there exists a way to cut out the substring, and 'NO' otherwise (without the quotes).

    Sample Input

    CODEWAITFORITFORCES

    Sample Output

    YES

    HINT

    题意

     给你一个字符串,然后让你删除一段字符,看是否能构成CODEFORCES

    题解:

    啊,枚举区间就好了……

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 200001
    #define mod 10007
    #define eps 1e-9
    int Num;
    char CH[20];
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=0x3f3f3f3f;
    /*
    
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    */
    inline ll read()
    {
        int x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    //**************************************************************************************
    
    
    string s;
    int a[maxn];
    string kiss="CODEFORCES";
    int main()
    {
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
    
            for(int j=i+1;j<=s.size();j++)
            {
                string p=s.substr(0,i)+s.substr(j);
                //cout<<p<<endl;
                if(p=="CODEFORCES")
                {
                    cout<<"YES"<<endl;
                    return 0;
                }
            }
        }
        cout<<"NO"<<endl;
    }
  • 相关阅读:
    Matlab绘图基础——利用axes(坐标系图形对象)绘制重叠图像 及 一图多轴(一幅图绘制多个坐标轴)
    [学习笔记]Javaweb开发视频教程之Tomcat9配置
    Matlab绘图基础——axis设置坐标轴取值范围
    Cauchy-Binet公式的证明 及 对《来自特征值的特征向量》的理解
    [问题解决]win10误删启动项(BCD)(HP电脑亲测,无需启动盘,并非重装系统)
    [经验分享]用自相似的思想来理解二叉树的三种遍历方法
    [参考]用递归的方法获取 字符 对应的 二进制字符串 (C/C++)
    [经验分享]SecureCRT导出操作日志 + Notepad自定义语言格式高亮日志文件
    [公式推导]一般线性秩统计量的方差函数 及其 极限分布
    [问题解决]RedHat7更换CentOS7的yum源时踩过的坑
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4458882.html
Copyright © 2011-2022 走看看