题意:给你一个原串和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. 【leetcode】453. Minimum Moves to Equal Array Elements

    problem 453. Minimum Moves to Equal Array Elements 相当于把不等于最小值的数字都减到最小值所需要次数的累加和. solution1: class So ...

  2. 【leetcode】438. Find All Anagrams in a String

    problem 438. Find All Anagrams in a String solution1: class Solution { public: vector<int> fin ...

  3. asp.net IE11 dopostback is null or undefined 为空或未定义

    个人认为这个问题一般是未按规范书写导致,但懒人嘛就有懒办法. 页面重构一般可以解决此问题,但是对于不便重写的情形,这里仍然有一个解决办法. 解决方法: 1.将文件ie11.browser拷贝到C:\W ...

  4. Python3 Flask+nginx+Gunicorn部署(上)

    前言:一般在本地运行flask项目通常是直接python3 文件名.py,然后打开:http://127.0.0.1:5000 查看代码结果 这次主要是记录flask在python3 环境结合ngin ...

  5. zombodb 索引管理

    zombodb 支持标准的index 管理(create .alter.drop) 创建索引 CREATE INDEX index_name ON table_name USING zombodb ( ...

  6. Spring Boot/Spring Cloud

    104.什么是 spring boot?         在Spring框架这个大家族中,产生了很多衍生框架,比如 Spring.SpringMvc框架等,Spring的核心内容在于控制反转(IOC) ...

  7. Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found

    Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found 网上大部分文章都是说在bios开启vt-x支持等.这里 ...

  8. Fabric实例

    Fabric的官网  http://fabric-chs.readthedocs.io/zh_CN/chs/index.html 参考<Python自动化运维 技术与最佳实践>   1:查 ...

  9. redis 的备份策略,最好使用:RDB-AOF 混合持久化

    相关资料: Redis 4.0 新功能简介:RDB-AOF 混合持久化:http://blog.huangz.me/2017/redis-rdb-aof-mixed-persistence.html ...

  10. Linux中redis安装配置及使用详解

    Linux中redis安装配置及使用详解 一. Redis基本知识 1.Redis 的数据类型 字符串 , 列表 (lists) , 集合 (sets) , 有序集合 (sorts sets) , 哈 ...