链接:

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. LeetCode 144. 二叉树的前序遍历(Binary Tree Preorder Traversal)

    144. 二叉树的前序遍历 144. Binary Tree Preorder Traversal 题目描述 给定一个二叉树,返回它的 前序 遍历. LeetCode144. Binary Tree ...

  2. linux 加载新的磁盘(卷组)

    pvcreate /dev/vdbvgcreate datavg /dev/vdblvcreate -n datalv -L 99.8G datavgmkfs.ext3 /dev/datavg/dat ...

  3. [转帖]java架构之路-(面试篇)JVM虚拟机面试大全

    java架构之路-(面试篇)JVM虚拟机面试大全 https://www.cnblogs.com/cxiaocai/p/11634918.html   下文连接比较多啊,都是我过整理的博客,很多答案都 ...

  4. 剑指offer62:二叉搜索树的第k个结点,二叉搜索树【左边的元素小于根,右边的元素大于根】

    1 题目描述 给定一棵二叉搜索树,请找出其中的第k小的结点.例如, (5,3,7,2,4,6,8)    中,按结点数值大小顺序第三小结点的值为4. 2 思路和方法 二叉搜索树[左边的元素小于根,右边 ...

  5. python学习-56 贪吃蛇🐍

    import random, pygame, sys from pygame.locals import * FPS = 15 WINDOWWIDTH = 640 WINDOWHEIGHT = 480 ...

  6. hadoop 伪分布启动-fs格式化

    1.独立模式(standalone|local) nothing! 本地文件系统. 不需要启用单独进程. 2.pesudo(伪分布模式) 等同于完全分布式,只有一个节点. SSH: //(Socket ...

  7. LeetCode每日一练(1-3)

    题目导航 1. 两数之和 2. 两数相加 3. 无重复字符的最长子串 1. 两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的 ...

  8. Windows下编译 Hadoop

    Windows下编译 Hadoop-2.9.2 系统环境 系统: Windows 10 10.0_x64 maven: Apache Maven 3.6.0 jdk: jdk_1.8.0_201 Pr ...

  9. 安卓开发之利用runOnUiThread在子线程更新UI

    package com.lidaochen.test; import android.graphics.Bitmap; import android.graphics.BitmapFactory; i ...

  10. ios获取数组中的最大值

    在编码过程中,我们通常碰到一组数据,需要自己简单的处理下,拿到数组中的总和,大小和平均值数据. 1.简单粗暴的方法,快速求和. NSArray * array = @[@"35", ...