【枚举】URAL - 2081 - Faulty dial
//._. ... ._. ._. ... ._. ._. ._. ._. ._.
//|.| ..| ._| ._| |_| |_. |_. ..| |_| |_|
//|_| ..| |_. ._| ..| ._| |_| ..| |_| ._|
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef pair<int,int> Point;
char table[10][3][4]={
{
"._.",
"|.|",
"|_|"
},
{
"...",
"..|",
"..|"
},
{
"._.",
"._|",
"|_."
},
{
"._.",
"._|",
"._|"
},
{
"...",
"|_|",
"..|"
},
{
"._.",
"|_.",
"._|"
},
{
"._.",
"|_.",
"|_|"
},
{
"._.",
"..|",
"..|"
},
{
"._.",
"|_|",
"|_|"
},
{
"._.",
"|_|",
"._|"
}
};
char b[3][30];
bool cant[5][10];
int l[5],r[5],n;
int main()
{
//freopen("d.in","r",stdin);
l[1]=0; r[1]=2;
l[2]=4; r[2]=6;
l[3]=10; r[3]=12;
l[4]=14; r[4]=16;
scanf("%d",&n);
Point Pre;
for(int i=1;i<=n;++i)
{
memset(cant,0,sizeof(cant));
for(int j=0;j<3;++j)
scanf("%s",b[j]);
for(int j=1;j<=4;++j)
{
for(int p=0;p<10;++p){
for(int k=0;k<3;++k)
for(int l1=0,l2=l[j];l1<3;++l1,++l2)
if(table[p][k][l1]=='.' && b[k][l2]!='.')
{
cant[j][p]=1;
goto OUT;
}
OUT:;
}
}
for(int j=9;j>=0;--j)
for(int k=9;k>=0;--k)
for(int l=9;l>=0;--l)
for(int p=9;p>=0;--p)
if((!cant[1][j]) && (!cant[2][k]) && (!cant[3][l]) && (!cant[4][p]) && (j<6 && l<6))
if(i==1 || Point(j*10+k,l*10+p)<Pre)
{
printf("%d%d:%d%d\n",j,k,l,p);
Pre=Point(j*10+k,l*10+p);
goto OU2;
}
OU2:;
}
return 0;
}
【枚举】URAL - 2081 - Faulty dial的更多相关文章
- URAL 2081 Faulty dial
题目: Faulty dial Pavel has not played ACM for ages, nor does he train teams, nor prepare problems. Th ...
- URAL 2078~2089
URAL 2078~2089 A - Bowling game 题目描述:给出保龄球每一局击倒的球数,按照保龄球的规则,算出总得分的最小值和最大值. solution 首先是最小值:每一局第一球击倒\ ...
- URAL 1792. Hamming Code (枚举)
1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersectin ...
- URAL 2031. Overturned Numbers (枚举)
2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the In ...
- URAL 1200 Horns and Hoofs 枚举
设horns和hoofs的数量分别为 x 和 y ,题目要求: 满足 x+y <= K,使得A*x + B*y - x*x - y*y 最大. 枚举 i 从0~K,直接解方程得对称轴 x = ( ...
- 【折半枚举】Ural Championship April 30, 2017 Problem G. Glasses with solutions
题意:有n杯盐溶液,给定每杯里面盐的质量以及盐溶液的质量.问你有多少种方案选择一个子集,使得集合里面的盐溶液倒到一个被子里面以后,浓度为A/B. 折半枚举,暴力搜索分界线一侧的答案数,跨越分界线的答案 ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
随机推荐
- 数学:乘法逆元-拓展GCD
乘法逆元应用在组合数学取模问题中,这里给出的实现不见得好用 给出拓展GCD算法: 扩展欧几里得算法是指对于两个数a,b 一定能找到x,y(均为整数,但不满足一定是正数) 满足x*a+y*b=gcd(a ...
- Spring - IoC(6): 作用域
Spring 支持五种作用域,分别是 singleton.prototype.request.session 和 global session. 作用域 说明 singleton (默认作用域)单例 ...
- UVa11988 Broken Keyboard (a.k.a. Beiju Text)
题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链 ...
- DotNETCore 学习笔记 全球化和本地化
Globalization and localization ********************************************************************* ...
- [bzoj1486][HNOI2009]最小圈——分数规划+spfa+负环
题目 传送门 题解 这个题是一个经典的分数规划问题. 把题目形式化地表示,就是 \[Minimize\ \lambda = \frac{\sum W_{i, i+1}}{k}\] 整理一下,就是 \[ ...
- Ansible 创建用户 Playbook 脚本
创建用户,设置wheel组sudo不需要密码,然后将用户添加到wheel组,并将用户的公钥传输到节点上: --- - name: Linux Create User and Upload User P ...
- MySQL 查询语句练习1
1.创建成绩表,字段包括:学生姓名,语文成绩,数学成绩,英语成绩 向表中插入多条数据: 查询: (1) 查询所有学生的数学成绩和总成绩 (2) 查询所有学生的语文和数学成绩和,按从高到低排序 (3) ...
- wxpython布局管理部件wx.gridbagsizer用法示例
text = ("This is text box") panel = wx.Panel(self, -1) chkAll1 = wx.CheckB ...
- SpringMvc基础知识(二) springmvc和mybatis整合
1 springmvc和mybatis整合 1.1 需求 使用springmvc和mybatis完成商品列表查询. 1.2 整合思路 springmvc+mybaits的系统架构: 第一步:整合dao ...
- 24式太极拳:3D动画演示(图文)
http://blog.sina.com.cn/s/blog_4be33b740102e9ae.html 24式太极拳:3D动画演示(图文) (2013-03-10 18:45:55) 转载▼ 标签: ...