题意:给你一个原串和n个子串,问你这n个子串任意组合起来能不能使原串出现,串的长度为2。

Examples
Input
ya
4
ah
oy
to
ha
Output
YES
Input
hp
2
ht
tp
Output
NO
Input
ah
1
ha
Output
YES

思路: 首先如果输入的就有原串那么肯定可以;若没有,那么就记录一下每个子串的第一个字母是否等于原串的第二个字母,
     第二个字母是否等于原串的
第一个字母,因为这样可以拼接起来构成原串,按照最后一个样例,好像每个子串可以用多次。 代码:
#include<iostream>
#include<string.h>
using namespace std; int main(){
    char c1,c2,a,b;
    int n,ans1=0,ans2=0;
    cin>>c1>>c2>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a==c1&&b==c2){
            cout<<"YES"<<endl;
            return 0;
        }
        if(b==c1)ans2++;
        if(a==c2)ans1++;
    }
    if(ans1&&ans2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Codeforces Round #438 A. Bark to Unlock的更多相关文章

  1. Codeforces Round #438 (Div.1+Div.2) 总结

    本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...

  2. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

    A. Bark to Unlock 题目链接:http://codeforces.com/contest/868/problem/A 题目意思:密码是两个字符组成的,现在你有n个由两个字符组成的字符串 ...

  3. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine

    最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛 A. Bark to Unlock time limit per test 2 seconds memory limit per t ...

  4. 【Codeforces Round 438 A B C D 四个题】

    题目所在比赛的地址在这里呀 A. Bark to Unlock ·述大意:       输入一个目标串.然后输入n(1<=n<=100)个串,询问是否可以通过这些串收尾相接或者它本身拼出目 ...

  5. 【Codeforces Round #438 A】Bark to Unlock

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] 枚举它是在连接处,还是就是整个字符串就好. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc+ ...

  6. Codeforces Round #438 B. Race Against Time

    Description Have you ever tried to explain to the coordinator, why it is eight hours to the contest ...

  7. Codeforces Round #438 C. Qualification Rounds

    Description Snark and Philip are preparing the problemset for the upcoming pre-qualification round f ...

  8. D. Huge Strings Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

    http://codeforces.com/contest/868/problem/D 优化:两个串合并 原有状态+ 第一个串的尾部&第二个串的头部的状态 串变为第一个串的头部&第二个 ...

  9. Codeforces Round #438 C - Qualification Rounds 思维

    C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

随机推荐

  1. js 点击下载文件

    下载的文件类型如果浏览器不能打开会直接下载,能打开的需要后台在响应头部进行设定. Content-disposition 是 MIME 协议的扩展,MIME 协议指示 MIME 用户代理如何显示附加的 ...

  2. SQL Analytic Functions 分析函数

    应用场景 主要使用在需要分组计算的场景中,根据所需的计算值可以分为两类: 1,排序类:如排序号,相邻记录等 2,聚合类:如平均值,累加求和,最大值,最末值等 语法 分析函数的语法在各大数据库中基本类似 ...

  3. python 多协程异步IO爬取网页加速3倍。

    from urllib import request import gevent,time from gevent import monkey#该模块让当前程序所有io操作单独标记,进行异步操作. m ...

  4. spring jpa + mybatis快速开始:

    springmvc开始搭建 源码地址 https://gitee.com/flydb/spingjpamy pom: <packaging>war</packaging> &l ...

  5. spring-boot入门总结

    1.org.springframework.web.bind.annotation不存在 错误的pom.xml <dependency> <groupId>org.spring ...

  6. python 0,1行列问题

    shape[0]-- 行 A.min(0) --A的按列最小值,生成一个行向量 >>> a = np.random.rand(3,3) >>> a array([[ ...

  7. hnsdfz -- 6.19 -- day4

    感觉还好…… 暴力分挂了很多不知道为什么…… 听说今天出题人hsh很劲…… c题正解是个奇怪的知识点…… 恩总的来说今天的节奏依旧很散(大课间去围观sdfz跑操了233 暴力分都写了但是似乎没有尝试脑 ...

  8. Html 页面载入内容前,显示 loading 效果。

    Html 内容 loading部分: <div id="sys-loading" class=""><div class="spin ...

  9. [zz]LyX中文问题

    http://www.cnblogs.com/biaoyu/archive/2012/04/28/2475318.html LyX是一款极为优秀的所见即所得的文档处理软件,与MS Word相比,其排版 ...

  10. access十万级数据分页

    最近的一个项目采用winform+access,但后来发现客户那边的数据量比较大,有数十万条数据.用sql语句进行分页,每次翻页加载都需要8秒钟左右,实在难以忍受. 后来百度了一下,发现一篇文章我的A ...