题意:给你一个原串和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. Scrapy、Scrapy-redis组件

    目录 Scrapy 一.安装 二.基本使用 1. 基本命令 2.项目结构以及爬虫应用简介 3. 小试牛刀 4. 选择器 5. 格式化处理 6.中间件 7. 自定制命令 8. 自定义扩展 9. 避免重复 ...

  2. 【leetcode】412. Fizz Buzz

    problem 412. Fizz Buzz solution: class Solution { public: vector<string> fizzBuzz(int n) { vec ...

  3. 框架tensorflow2

    TensorFlow 2 TensorFlow 激励函数 TensorFlow 添加层: 思考:matmul和multiply两种乘法的区别:http://www.soaringroad.com/?p ...

  4. 【开发遇到的问题】Spring Mvc使用Jackson进行json转对象时,遇到的字符串转日期的异常处理(JSON parse error: Can not deserialize value of type java.util.Date from String[)

    1.问题排查 - 项目配置 springboot 2.1 maven配置jackson - 出现的场景: 服务端通过springmvc写了一个对外的接口,查询数据中的表,表中有一个字段属性是时间戳,返 ...

  5. 搭建简单的FTP服务器

    客户端部分主要使用C#提供的webclient类 (https://msdn.microsoft.com/library/system.net.webclient.aspx) 通过WebClient. ...

  6. django 生产环境部署建议

    参考django官方建议 一种优秀的作法是使用前缀/ws/来区分WebSocket连接和普通HTTP连接,以便修改配置后,使Channels更容易部署到生产环境中. 特别是对于大型站点,可以配置像ng ...

  7. Qt对`vtable的未定义引用

    错误描述:Qt在linux系统编译时,遇到一个错误大致如下形式 在 xxxxx函数中 对‘vtable for xxxxx未定义的引用 网上找了很多,各种情况都有,大多数是虚函数未实现导致的, 但也有 ...

  8. 命令:jstack(查看线程)、jmap(查看内存)和jstat(性能分析)命令

    命令:jstack(查看线程).jmap(查看内存)和jstat(性能分析)命令 这些命令 必须 在 linux jdk bin 路径 下执行 eq: ./jstack 10303 即可  如果想把 ...

  9. Python 面向对象(三)

    继承的实现原理 Python支持多继承 多继承的时候  属性查找的顺序 研究经典类和新式类在属性查找的不同 主要是形成菱形关系才有深度跟广度 广度优先 Python的继承原理  Python3的内置方 ...

  10. SQL 中 CASE - WHEN - THEN - ELSE - END 的小结

    在SQLServer中给变量赋备件值 可以用 @var = CASE WHEN EXPRESSION THEN STATEMENT01 ELSE STATEMENT02 END 当表达式 EXPRES ...