Tyche 2317 Color
题目大意:有三个人alice,bob,yazid,三种颜色red,blue,green,每个人对应一种颜色。
[name] is [color].
Yazid会做以下操作:
1 将三个句子连在一起
2 去掉逗号和空格
3 全部转换为小写
Alice,Bob会在串中加入任意小写字母。
现给定最后的串,求开始的串。
答案可能有多种,输出字典序最小的一种。
思路:一开始以为很复杂,一看就是一个搜索。
先找名字再找is最后找颜色,重复三次即可得到结果。
考试的时候把字典序理解错了,疯狂0分,换了个搜索顺序就ac了,血亏。
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int T,a[][];
char ch[],name[][]={"alice","bob","yazid"},nm[][]={"Alice","Bob","Yazid"},color[][]={"blue","green","red"},pd[]={"is"};
bool flag,b1[],b2[];
int fnd(int s,char c)
{
int l=strlen(ch+);
for(int i=s;i<=l;i++)
if(ch[i]==c)
return i;
return -;
}
void dfs(int x,int k,int s,int e)
{
if(x==&&!flag)
{
flag=;
for(int i=;i<=;i++)
printf("%s %s %s.",nm[a[i][]],pd,color[a[i][]]);
printf("\n");
}
if(k==)//??
{
for(int i=;i<=;i++)
if(!b1[i])
{
bool flg=;
int p=s;
for(int j=;j<strlen(name[i]);j++)
{
p=fnd(p,name[i][j]);
if(p==-)
{
flg=;
break;
}
p++;
}
if(!flg)
{
b1[i]=;
a[x][]=i;
dfs(x,,p,e);
b1[i]=;
}
}
}
else if(k==)
{
bool flg=;
int p=s;
for(int j=;j<;j++)
{
p=fnd(p,pd[j]);
if(p==-)
{
flg=;
break;
}
p++;
}
if(!flg)
dfs(x,,p,e);
}
else
{
for(int i=;i<=;i++)
if(!b2[i])
{
bool flg=;
int p=s;
for(int j=;j<strlen(color[i]);j++)
{
p=fnd(p,color[i][j]);
if(p==-)
{
flg=;
break;
}
p++;
}
if(!flg)
{
b2[i]=;
a[x][]=i;
dfs(x+,,p,e);
b2[i]=;
}
}
}
}
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%s",ch+);
flag=;
dfs(,,,strlen(ch+));
if(!flag)
printf("No solution.\n");
}
return ;
}
Tyche 2317 Color的更多相关文章
- 【转】c#、wpf 字符串,color,brush之间的转换
转自:http://www.cnblogs.com/wj-love/archive/2012/09/14/2685281.html 1,将#3C3C3C 赋给background this.selec ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- Python为8bit深度图像应用color map
图片中存在着色版的概念,二维矩阵的每个元素的值指定了一种颜色,因此可以显示出彩色. 迁移调色板 下述python代码将VOC数据集中的某个语义分割的图片的调色板直接应用在一个二维矩阵代表的图像上 #l ...
- (转)System.Drawing.Color的颜色对照表
经常使用System.Drawing.Color, 本篇介绍一下颜色与名称及RGB值的对应关系. 1. 颜色与名称的对照表(点击下图放大看): 2. 颜色与RGB值对照表: Color.AliceBl ...
- 激光打印机的Color/paper, Xerography介绍
Color Basic 看见色彩三要素: 光源,物体,视觉 加色色彩模型:R,G,B 多用于显示器 减色色彩模型:C,M,Y,K 多用于打印复印 Paper 东亚地区常用A系列标准用纸,在多功能一体机 ...
- 安卓工具箱:color of Style
<?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...
- UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
在 IOS 中,对 UIScrollView 的滚动条(ScrollBar Indicators)的自定义设置接口,一直都是很少的.除了能自定义简单的样式(UIScrollViewIndicatorS ...
- OpenCASCADE Color Scale
OpenCASCADE Color Scale eryar@163.com Abstract. The color scale is a specialized label object that d ...
- Color Transfer between Images code实现
上计算机视觉课老师布置的作业实现论文:Color Transfer between Images 基本思路是: 1.给定srcImg和targetImg 2.将RGB空间转为Lab空间 3.根据论文中 ...
随机推荐
- ThinkPHP+JQuery实现文件的异步上传
前端代码 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF- ...
- 开源Dapper的Lambda扩展-Sikiro.Dapper.Extension V2.0
前言 去年我在业余时间,自己整了一套dapper的lambda表达式的封装,原本是作为了一个个人的娱乐项目,当时也只支持了Sql Server数据库.随之开源后,有不少朋友也对此做了试用,也对我这个项 ...
- Java的并发及锁
Java并发编程:用AQS写一把可重入锁 https://blog.csdn.net/zhang5476499/article/details/83796289 线程的同步时可以使一个线程阻塞而等待一 ...
- Java面试之高并发系统
在开发高并发系统时有三把利器用来保护系统:缓存.降级和限流.
- shell 读取配置文件的方法
原文地址:http://bbs.chinaunix.net/thread-3628456-1-1.html 总结地址:https://www.cnblogs.com/binbinjx/p/568021 ...
- hibernate延迟加载org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.javakc.hibernate.onetomany.entity.DeptEntity.emp, could not initialize proxy - no Session
public static void main(String[] args) { DeptEntity dept = getDept("402882e762ae888d0162ae888e ...
- mysql有多大内存?能存多少数据?
Mysql: MySQL 3.22 限制的表大小为4GB. MyISAM 存储引擎: 最大表尺寸增加到了65536TB(2567 – 1字节).由于允许的表尺寸更大,MySQL数据库的最大有效表尺寸通 ...
- JS典记
var href = ""; //遍历a标签 $ ( "a"). each (function () { href = ...
- 打开指定测试App的指定Activity
那究竟应该如何让appium去自动找到指定的APP和指定的Activity呢?想要打开指定的App,需要知道App的包名,同样想要打开指定Activity也需要知道其名,如何获取? 1.问公司的开发人 ...
- Python_服务器与多客户端通信、UDP协议、pycharm打印带颜色输出、时间同步的机制
1.服务器与多客户端通信 import socket # 创建tcp socket的套接字 sk = socket.socket() # bind sk.bind(('127.0.0.1',8080) ...