• nbuoj 1532 New String


    • [1532] New String

    • 时间限制: 2000 ms 内存限制: 65535 K
    • 问题描述
    • Ceil so love the new string.
      If you can erase any character from the string, and use the remain character by any order to comprise the "new" , the string is the new string, otherwise not.
      Give you some string, you should help Ceil determine whether the string is the new string.

    • 输入
    • There are multiple test cases. For each test case:
      There is a string only contain the lowercase (1 <= string's length <= 1000).
    • 输出
    • If the string is the new string ,output "YES", otherwise output "NO".
    • 样例输入
    • aaneaw
      nneeaa
      wanaaea
    • 样例输出
    • YES
      NO
      YES

    思路:这是这场比赛里面最简单的一道题了,题意就是给你一个字符串,去掉一个字符,看看里面是否还同时存在'n','e','w'三个字符。PS:比 赛的时候第一次提交竟然没有加文件结束符号,返回一次TLE···nc啊

    代码如下:

     1 /*
     2 ID: asif
     3 LANG: C++
     4 TASK: test
     5 */
     6 //# pragma comment(linker, "/STACK:102400000,102400000")
     7 # include<iostream>
     8 # include<cstdio>
     9 # include<cstdlib>
    10 # include<cstring>
    11 # include<algorithm>
    12 # include<cctype>
    13 # include<cmath>
    14 # include<string>
    15 # include<set>
    16 # include<map>
    17 # include<stack>
    18 # include<queue>
    19 # include<vector>
    20 # include<numeric>
    21 using namespace std;
    22 const int maxn=1111;
    23 const double inf=0.000001;
    24 const int INF=~0U>>1;
    25 const int mod=1000000007;
    26 # define lson l,m,rt<<1
    27 # define rson m+1,r,rt<<1 | 1
    28 # define PS printf("
    ")
    29 # define S(n) scanf("%d",&n)
    30 # define P(n) printf("%d
    ",n)
    31 # define Ps(n) printf(" %d",(n))
    32 # define SB(n) scanf("%lld",&n)
    33 # define PB(n) printf("%lld
    ",n)
    34 # define PBs(n) printf(" %lld",n)
    35 # define SD(n) scanf("%lf",&n)
    36 # define PD(n) printf("%.3lf
    ",n)
    37 # define Sstr(s) scanf("%s",s)
    38 # define Pstr(s) printf("%s
    ",s)
    39 # define S0(a) memset(a,0,sizeof(a))
    40 # define S1(a) memset(a,-1,sizeof(a))
    41 typedef long long ll;
    42 char str[maxn];
    43 int a[6];
    44 int main()
    45 {
    46     //freopen("input.in", "r", stdin);
    47     //freopen("output.out", "w", stdout);
    48     while(~Sstr(str))
    49     {
    50         int l=strlen(str);
    51         S0(a);
    52         for(int i=0;i<l;i++)
    53         {
    54             if(str[i]=='n')
    55                 a[0]++;
    56             else if(str[i]=='e')
    57                 a[1]++;
    58             else if(str[i]=='w')
    59                 a[2]++;
    60             else
    61                 a[3]++;
    62         }
    63         if((a[0]&&a[1]&&a[2]&&a[3])||(a[0]&&a[2]&&a[1]&&(a[0]+a[1]+a[2]>3)))
    64             puts("YES");
    65         else
    66             puts("NO");
    67     }
    68     return 0;
    69 }
    View Code
  • 相关阅读:
    冒泡排序法
    冒泡排序法
    【HAOI2008】圆上的整点
    2018年全国多校算法寒假训练营练习比赛(第四场)F:Call to your teacher
    (java)Jsoup爬虫学习--获取网页所有的图片,链接和其他信息,并检查url和文本信息
    CSS 选择器
    (java)selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出
    (java)selenium webdriver学习---三种等待时间方法:显式等待,隐式等待,强制等待
    使用D3绘制图表(5)--水平柱状图表
    使用D3绘制图表(4)--面积图表
  • 原文地址:https://www.cnblogs.com/asif/p/3536295.html
Copyright © 2020-2023  润新知