链接:

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

题意:

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.

思路:

记录每个串的可用字符, DFS。

代码:

#include<bits/stdc++.h>
using namespace std; const int MAXN = 2e6+10; char s[6][MAXN];
int Vis[6][7];
int Use[7];
map<char, int> Mp; bool Dfs(int step)
{
//cout << step << endl;
if (step == 7)
return true;
for (int i = 0;i < 6;i++)
{
if (Use[i] == 1 || Vis[i][step] == 0)
continue;
Use[i] = 1;
if (Dfs(step+1))
return true;
Use[i] = 0;
}
return false;
} int main()
{
Mp['h'] = 1;
Mp['a'] = 2;
Mp['r'] = 3;
Mp['b'] = 4;
Mp['i'] = 5;
Mp['n'] = 6;
int t;
scanf("%d", &t);
while(t--)
{
memset(Use, 0, sizeof(Use));
memset(Vis, 0, sizeof(Vis));
for (int i = 0;i < 6;i++)
scanf("%s", s[i]);
for (int i = 0;i < 6;i++)
{
int len = strlen(s[i]);
for (int j = 0;j < len;j++)
{
if (Mp[s[i][j]] == 0)
continue;
Vis[i][Mp[s[i][j]]] = 1;
}
}
/*
for (int i = 0;i < 6;i++)
{
for (int j = 1;j <= 6;j++)
cout << Vis[i][j] << ' ';
cout << endl;
}
*/
if (Dfs(1))
puts("Yes");
else
puts("No");
} return 0;
}

The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners的更多相关文章

  1. The 2019 China Collegiate Programming Contest Harbin Site

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

  2. The 2019 China Collegiate Programming Contest Harbin Site K. Keeping Rabbits

    链接: https://codeforces.com/gym/102394/problem/K 题意: DreamGrid is the keeper of n rabbits. Initially, ...

  3. The 2019 China Collegiate Programming Contest Harbin Site J. Justifying the Conjecture

    链接: https://codeforces.com/gym/102394/problem/J 题意: The great mathematician DreamGrid proposes a con ...

  4. The 2019 China Collegiate Programming Contest Harbin Site I. Interesting Permutation

    链接: https://codeforces.com/gym/102394/problem/I 题意: DreamGrid has an interesting permutation of 1,2, ...

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

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

  6. 2019 China Collegiate Programming Contest Qinhuangdao Onsite F. Forest Program(DFS计算图中所有环的长度)

    题目链接:https://codeforces.com/gym/102361/problem/F 题意 有 \(n\) 个点和 \(m\) 条边,每条边属于 \(0\) 或 \(1\) 个环,问去掉一 ...

  7. The 2017 China Collegiate Programming Contest, Hangzhou Site Solution

    A: Super_palindrome 题面:给出一个字符串,求改变最少的字符个数使得这个串所有长度为奇数的子串都是回文串 思路:显然,这个字符串肯定要改成所有奇数位相同并且所有偶数位相同 那统计一下 ...

  8. 2019 China Collegiate Programming Contest Qinhuangdao Onsite

    传送门 D - Decimal 题意: 询问\(\frac{1}{n}\)是否为有限小数. 思路: 拆质因子,看是不是只包含2和5即可,否则除不尽. Code #include <bits/st ...

  9. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

随机推荐

  1. pycharm远程调试或运行代码

    第一步:开始 第二步:设置远程服务器 第三步,查看 第四步,选择解释器,和指定文件映射路径(相对上一步指定的相对路径)

  2. 有助提升编程的几个Python 技巧

    一行代码定义List 定义某种列表时,写For 循环过于麻烦,幸运的是,Python有一种内置的方法可以在一行代码中解决这个问题. 下面是使用For循环创建列表和用一行代码创建列表的对比. x = [ ...

  3. [转帖]Nginx rewrite 规则 与 proxy_pass 实现

    Nginx rewrite 规则 与 proxy_pass 实现 https://www.cnblogs.com/jicki/p/5546916.html Nginx rewrite 规则  与 pr ...

  4. Word 文档内超级链接跳转到书签

    1. 前言 在Word文档内如何实现一些跳转的超链接呢?Word中,一些外部链接,我们通常叫作超链接,内部链接我们可以叫书签.如何在文档中如何使用书签,跳转到指定位置? 这里我在网上随便找了一份模拟试 ...

  5. 小程序的目录结构/配置介绍/视图层wxml数据绑定/双线程模型/小程序的启动流程

    安装好微信小程序开发软件,创建项目 小程序文件结构和传统web对比 结构 传统web 微信小程序 结构 HTML WXML 样式 CSS WXSS 逻辑 Javascript Javascript 配 ...

  6. Linux 进程地址空间及原理

    1.程序地址空间      首先,我们先看学c/c++时候学到的程序内存布局: 准确地说,程序地址空间其实就是进程的地址空间,实际就是pcb中的mm_struct. 接下来,我们用fork()演示一下 ...

  7. ArcGIS Server Identify结果属性 AliasName

    最近做地图服务相关工作,一般在数据库中,字段名有好多限制,而实际工作中,需要显示的经常有一些较长的字段或者包含单位等特殊符号. 为了方便属性的操作,将属性字段名改为英文,AliasName中保存了属性 ...

  8. drbd+nfs+keepalived

    写的很详细 理论知识: https://www.cnblogs.com/kevingrace/p/5740940.html 写的很详细 负载: https://www.cnblogs.com/kevi ...

  9. hdu 2539 虽然是水题 wa了很多次 说明自己的基本功不扎实 需要打好基础先 少年

    两点吧 1.gets使用的时候 确保上一次的回车符对其没有影响 getline也是如此 这样的细节..  多注意啊!! 2.编写程序的时候 对一些极端的情况要多调试 比如此题当 n==1的时候..  ...

  10. PHP即时实时输出内容

    一般情况下,PHP都是将整个页面全部执行完成后,才会把要输出的内容发送回客户端. for ($i = 0; $i < 10; $i++) { echo $i; sleep(1); } 这段代码会 ...