【枚举】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 ...
随机推荐
- ViBe(Visual Background extractor)背景建模或前景检测
ViBe算法:ViBe - a powerful technique for background detection and subtraction in video sequences 算法官网: ...
- [ST表/贪心] NOI2010 超级钢琴
[NOI2010]超级钢琴 题目描述 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i ...
- [poj 1743]差分+后缀数组
题目链接:http://poj.org/problem?id=1743 首先,musical theme只与前后位置的增减关系有关,而与绝对的数值无关,因此想到做一次差分. 然后对于差分后的数组,找到 ...
- Educational Codeforces Round 58 (Rated for Div. 2) 题解
Educational Codeforces Round 58 (Rated for Div. 2) 题目总链接:https://codeforces.com/contest/1101 A. Min ...
- codeforces 1077D
题目:https://codeforces.com/contest/1077/problem/D 题意:给你一个长度为n的串,你需要在里面找到出现次数最多的长度为k的子序列(子序列中元素可重复),求这 ...
- Optimize Prime Sieve
/// A heavily optimized sieve #include <cstdio> #include <cstring> #include <algorith ...
- 线程 ManualResetEvent 类
Reset(): 当一个线程开始一个活动(此活动必须完成后,其他线程才能开始)时, 它调用 Reset 以将 ManualResetEvent 置于非终止状态.此线程可被视为控制 ManualRese ...
- python每隔一段时间做一个事情
#!/usr/bin/env python #coding:utf8 #Author:lsp #Date:下午2:17:54 #Version:0.1 #Function: 每隔一段时间做一个事情 f ...
- css做中划线与文字排版
html: <div class="spilt"> <span class="left"></span> < ...
- poj 2406 Power Strings(kmp循环节)
题目链接:http://poj.org/problem?id=2406 题目大意:如果n%(n-next[n])==0,则存在重复连续子串,长度为n-next[n]. 例如: a b ...