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啊

 

代码如下:

 

nbuoj 1532 New String
 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("\n")
29 # define S(n) scanf("%d",&n)
30 # define P(n) printf("%d\n",n)
31 # define Ps(n) printf(" %d",(n))
32 # define SB(n) scanf("%lld",&n)
33 # define PB(n) printf("%lld\n",n)
34 # define PBs(n) printf(" %lld",n)
35 # define SD(n) scanf("%lf",&n)
36 # define PD(n) printf("%.3lf\n",n)
37 # define Sstr(s) scanf("%s",s)
38 # define Pstr(s) printf("%s\n",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

nbuoj 1532 New String

上一篇:oracle 11g ocr 冗余配置


下一篇:看懂Gradle脚本(6)- Hello Groovy, Goodbye Getters&Setters