http://codeforces.com/gym/102394/problem/F

F. Fixing Banners
time limit per test

1 second

memory limit per test

512 megabytes

input

standard input

output

standard output

Harbin, whose name was originally a Manchu word meaning "a place for drying fishing nets", grew from a small rural settlement on the Songhua River to become one of the largest cities in Northeast China. Founded in 1898 with the coming of the Chinese Eastern Railway, the city first prospered as a region inhabited by an overwhelming majority of the immigrants from the Russian Empire. Now, Harbin is the capital of Heilongjiang province and the largest city in the northeastern region of the People's Republic of China. It serves as a key political, economic, scientific, cultural, and communications hub in Northeast China, as well as an important industrial base of the nation.

This year, a CCPC regional contest is going to be held in this wonderful city, hosted by Northeast Forestry University. To ensure the contest will be a success and enjoyed by programmers around the country, preparations for the event are well underway months before the contest.

You are the leader of a student volunteer group in charge of making banners to decorate the campus during the event. Unfortunately, your group made a mistake and misprinted one of the banners. To be precise, the word "harbin" is missing in that banner. Because you don't have time to reprint it, the only way to fix it is to cut letters from some used old banners and paste them onto the misprinted banner. You have exactly six banners, and for some reason, you must cut exactly one letter from each banner. Then, you can arrange and paste the six letters onto the misprinted banner and try to make the missing word "harbin". However, before you start cutting, you decide to write a program to see if this is possible at all.

Input

The input contains multiple cases. The first line of the input contains a single integer T (1≤T≤50000)

, the number of cases.

For each case, the input contains six lines. Each line contains a non-empty string consisting only of lowercase English letters, describing the letters on one of the old banners.

The total length of all strings in all cases doesn't exceed 2⋅106

.

Output

For each case, print the string "Yes" (without quotes) if it is possible to make the word "harbin", otherwise print the string "No" (without quotes).

Example
Input

Copy
2
welcome
toparticipate
inthe
ccpccontest
inharbin
inoctober
harvest
belong
ninja
reset
amazing
intriguing
Output

Copy
No
Yes
题意:从六个字符串中分别找出一个字符,问能否组成“harbin“字符串。
解法:dfs搜索;
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF 0x3f3f3f3f
#define mod 998244353
#define PI acos(-1)
using namespace std;
typedef long long ll ;
char s[][];
int vis[][];
int v[];
int flag ; void dfs(int num)
{
if(flag) return ;
if(num >= )
{
flag = ;
return ;
}
for(int i = ; i <= ; i++)
{
if(!v[i] && vis[i][num])
{
v[i] = ;
dfs(num+);
v[i] = ;
}
}
} int main()
{
int t;
scanf("%d" , &t);
int p = t ;
while(t--)
{
if(p == t + )
getchar();
memset(vis , , sizeof(vis));
memset(v , , sizeof(v));
for(int i = ; i <= ; i++)
{
char c ;
while(c = getchar())
{
if(c == '\n') break ;
else if(c == 'h')
vis[i][] = ;
else if(c == 'a')
vis[i][] = ;
else if(c == 'r')
vis[i][] = ;
else if(c == 'b')
vis[i][] = ;
else if(c == 'i')
vis[i][] = ;
else if(c == 'n')
vis[i][] = ;
}
}
flag = ;
dfs();
if(flag)
cout << "Yes" << endl ;
else
cout << "No" << endl ;
} return ;
}

F. Fixing Banners的更多相关文章

  1. The 2019 China Collegiate Pro gramming Contest Harbin Site (F. Fixing Banners)

    F. Fixing Banners time limit per test 1 second memory limit per test 512 megabytes input standard in ...

  2. The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners

    链接: https://codeforces.com/gym/102394/problem/F 题意: Harbin, whose name was originally a Manchu word ...

  3. The 2019 China Collegiate Programming Contest Harbin Site

    题解: https://files.cnblogs.com/files/clrs97/HarbinEditorialV2.zip Code: A. Artful Paintings /* let x= ...

  4. 模拟赛小结:The 2019 China Collegiate Programming Contest Harbin Site

    比赛链接:传送门 上半场5题,下半场疯狂挂机,然后又是差一题金,万年银首也太难受了. (每次银首都会想起前队友的灵魂拷问:你们队练习的时候进金区的次数多不多啊?) Problem J. Justify ...

  5. Mysql_以案例为基准之查询

    查询数据操作

  6. F. Igor and Interesting Numbers

    http://codeforces.com/contest/747/problem/F cf #387 div2 problem f 非常好的一道题.看完题,然后就不知道怎么做,感觉是dp,但是不知道 ...

  7. 在 C# 里使用 F# 的 option 变量

    在使用 C# 与 F# 混合编程的时候(通常是使用 C# 实现 GUI,F#负责数据处理),经常会遇到要判断一个 option 是 None 还是 Some.虽然 Option module 里有 i ...

  8. 如果你也会C#,那不妨了解下F#(7):面向对象编程之继承、接口和泛型

    前言 面向对象三大基本特性:封装.继承.多态.上一篇中介绍了类的定义,下面就了解下F#中继承和多态的使用吧.

  9. 如果你也会C#,那不妨了解下F#(2):数值运算和流程控制语法

    本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-2.html 一些废话 一门语言火不火,与语言本身并没太大关系,主要看语言的推广. 推广得好,用的 ...

随机推荐

  1. linux 上配置swoole

    1.首先我们要安装swoole扩展的话,需要把它的包下载下来,下载地址是: https://github.com/swoole/swoole-src 本人qq群也有许多的技术文档,希望可以为你提供一些 ...

  2. webpack Entrypoint undefined = index.html

    报错: module.exports增加配置stats: { children: false }即可解决:

  3. js 动态时间

    <script type="text/javascript"> function show_cur_times(){ //获取当前日期 var date_time = ...

  4. flask基础之一

    flask基础之一 hello world #从flask这个包中导入Flask这个类 #Flask这个类是项目的核心,以后的很多操作都是基于这个类的对象 #注册url,注册蓝图都是这个类的对象 fr ...

  5. Facebook再现丑闻,约100位应用程序开发人员偷看用户数据

    Facebook今天披露了另一起安全事件,承认大约100名应用程序开发人员可能不正确地访问了某些Facebook组中的用户数据,包括他们的姓名和个人资料图片. 在周二发布的博客文章中,Facebook ...

  6. vue制作分页

    怎么制作分页?得先把思路路通顺了才可以. 我制作过程中遇到3个问题: 1,问:制作分页需要什么数据?怎么关联起来?       答:分页数据内容包含几部分, 1,当前是第几页?或则说当前默认是第几页. ...

  7. C# 字符串的长度问题

    string str = "aa奥奥"; 如果直接取 str.length,取的就是字符的长度,一个汉字也是一个字符,长度就是4. 一个汉字是两个字节,如果需要统计字节数,可以用下 ...

  8. 洛谷P1309 瑞士轮——题解

    题目传送 思路非常简单,只要开始时把结构体排个序,每次给赢的加分再排序,共r次,最后再输出分数第q大的就行了. (天真的我估错时间复杂度用每次用sort暴力排序结果60分...)实际上这道题估算时间复 ...

  9. Windows 搭建Hadoop 2.7.3开发环境

    1.安装配置Java环境 1.1.安装Windows版本的jkd应用程序 当前的系统环境是64位Windows 7,因此下载64位JDK,下载地址:http://download.oracle.com ...

  10. 170905-MyBatis中的关系映射

    ===关系映射=== 参考文档复习:1对1,1对多,多对多 1.映射(多)对一.(一)对一的关联关系 1).使用列的别名 ①.若不关联数据表,则可以得到关联对象的id属性 ②.若还希望得到关联对象的其 ...