题意:给你一个原串和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. Centos6.8 编译安装Apache2.4

    cetos6.8源码安装apache2.4.29 apache官网:http://httpd.apache.org 具体安装步骤: 1 配置安装apache的基础环境2 下载想要安装的版本源码包3 解 ...

  2. win10企业版2016长期服务版本激活

    右键左下角Windows开始图标  ——>  单击  命令提示符(管理员)A 粘贴如下代码到dos窗口: slmgr /ipk DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ slm ...

  3. JS 验证字符串是否为空

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. android ListView 可缩放,支持左右上下手势

    public class ZoomListView extends ListView implements SwipeListener { public static enum Action { Le ...

  5. 利用STM32CubeMX来生成USB_HID_Mouse工程【添加ADC】(2)【非dma和中断方式】

    上回讲到怎么采集一路的adc的数据,这次我们来采集两路的数据. 现在直接修改原先的代码 /* Private variables ----------------------------------- ...

  6. Python输入语句

    什么是输入 咱们在银行ATM机器前取钱时,肯定需要输入密码,对不? 那么怎样才能让程序知道咱们刚刚输入的是什么呢?? 大家应该知道了,如果要完成ATM机取钱这件事情,需要先从键盘中输入一个数据,然后用 ...

  7. <realsense D400>同步采集深度图和彩色图

    利用深度相机采集深度图和彩色图会面临一个问题,如何实现同步采集数据? 以下是我搜集到的两点方法: 1)高翔博士提到他的orbslam2教程有这么一步工作,具体目录为 example/RGBD/. (等 ...

  8. android升级gradle到3.4.1

    这两天把gradle升级到了gradle-3.4.1 com.android.tools.build:gradle升级到了com.android.tools.build:gradle:2.3.0 结果 ...

  9. jsp 进度条

    <html>  <head>  <title>进度条</title>  <style type="text/css">  ...

  10. VS2010自定义添加创建者、创建时间等个人信息新建文件模版

    不知不觉VS2010已经成为.NET开发人员的必备工具,相比经典版VS2005,到过渡版vs2008,2010在性能稳定性和易用性上都得到很大的提高. 结合VS工具,其下的插件也层出不穷.今天重点给大 ...