BC一周年B

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <stack>
#include <set>
#include <map>
#include <vector>

using namespace std;
#define INF 0x4fffffff
#define LL long long
#define MAX(a,b) ((a)>(b))?(a):(b)
#define MIN(a,b) ((a)<(b))?(a):(b)
char str[] = "anniversary";
int a[300][4] = {};
char st[105];
int main(){
    int t;
    cin >> t;
    int len = strlen(str);
    int w = 0;
    for(int i = 0;i < len-2;i++){
        for(int j = i+1;j < len-1;j++){
                a[w][0] = i;
                a[w][1] = j;
                a[w][2] = len-1;
                w++;
        }
    }
    while(t--){
        scanf("%s",st);
        len = strlen(st);
        int flag = 0;
        int s,e,g,f;
        for(int i = 0;i < w;i++){
            s = 0;
            f = 0;
            g = 0;
            for(int j =  0;j < 3;j++){
                e = a[i][j];
                for(int k = g;k < len;k++){
                    int d = 0;
                    int status = 0;
                    while(str[s+d] == st[k+d] && s+d <= e && k+d < len){
                        if(s+d == e){
                            f ++;
                            s = a[i][j]+1;
                            g = k+d+1;
                            status = 1;
                            break;
                        }
                        d ++;
                    }
                    if(status){
                        break;
                    }
                }
            }

            if(f == 3){
                flag = 1;
                break;
            }
        }
        if(flag){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}
时间: 2024-12-28 09:48:21

BC一周年B的相关文章

(BC 一周年)hdu 5311 Hidden String

Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描述 今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为nn的字符串ss. 他想要知道能否找到ss的三个互不相交的子串s[l_1..r_1]s[l?1??..r?1??], s[l_2..r_2]s[l?2??..r?2

bc 一周年 1001 Souvenir (hdu 5310)

Souvenir Accepts: 901 Submissions: 2743 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描述 今天是BestCoder一周年纪念日. 比赛管理员Soda想要给每个参赛者准备一个纪念品. 商店里纪念品的单价是$p$元, 同时也可以花$q$元购买纪念品套装, 一个套装里有$m$个纪念品. 今天总共有$n$个参赛者, Soda想要知道最少需要

(BC 一周年) hdu 5312 Sequence

Sequence Accepts: 25 Submissions: 1442 Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描述 Soda习得了一个数列, 数列的第nn (n \ge 1)(n≥1)项是3n(n-1)+13n(n−1)+1. 现在他想知道对于一个给定的整数mm, 是否可以表示成若干项上述数列的和. 如果可以, 那么需要的最小项数是多少? 例如, 22可以表示

BC一周年A

#include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <cmath> #include <cstring> #include <stack> #include <set> #include <map> #include <vector> using namespace st

BC一周年练习赛

Souvenir Accepts: 901 Submissions: 2743 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, wants to buy a souvenir for each cont

桥砸盐苁旁xedsw404oc23mr99m04

http://www.gxxc.gov.cn/Town/TownDetails?id=94210&town=%e6%97%a5%e7%85%a7%e6%b0%b0%e5%8c%96%e9%92%a0%e5%93%aa%e9%87%8c%e4%b9%b0%2b%ef%bd%91Q%e2%92%89%e2%92%8f%e2%92%8c%e2%92%8f%e2%92%89%e2%92%90%e2%92%88%e2%92%89O.http://www.gxxc.gov.cn/Town/TownDetai

苊旅钨谧孪xj0q8q8964kh110yu3

http://www.qiushibaike.com/tag/%e4%b8%89%e6%b2%b3%e5%93%aa%e9%87%8c%e6%9c%89%e6%9b%b2%e9%a9%ac%e5%a4%9a%e5%8d%96%2b%ef%bd%91%ef%bc%92%ef%bc%98%ef%bc%95%ef%bc%98%ef%bc%92%ef%bc%99%ef%bc%91%ef%bc%92%ef%bc%90.http://www.qiushibaike.com/tag/%e6%b1%9f%e9%

厦仄丝咱苤fnvm98414674g86633

http://www.gxxc.gov.cn/Town/TownDetails?id=94210&town=%e5%93%aa%e9%87%8c%e6%9c%89%e5%8d%96%e6%9b%b2%e9%a9%ac%e5%a4%9a%2b%ef%bd%91Q%e2%92%89%e2%92%8f%e2%92%8c%e2%92%8f%e2%92%89%e2%92%90%e2%92%88%e2%92%89O.http://www.gxxc.gov.cn/Town/TownDetails?id=942

嗣抢迷巧绦hl9i938f45my6h

http://www.gxxc.gov.cn/Town/TownDetails?id=94210&town=%e6%94%80%e6%9e%9d%e8%8a%b1%e5%82%ac%e6%83%85%e8%8d%af%e5%93%aa%e9%87%8c%e4%b9%b0%2b%ef%bd%91Q%e2%92%89%e2%92%8f%e2%92%8c%e2%92%8f%e2%92%89%e2%92%90%e2%92%88%e2%92%89O.http://www.gxxc.gov.cn/Town/