UVa12478 - Hardest Problem Ever (枚举)

简介: UVa12478 - Hardest Problem Ever (枚举)
#include <cstdio>#include <string>#include <algorithm>usingnamespacestd;
constintN=9;
chartable[N][N] = {
                       {'O', 'B', 'I', 'D', 'A', 'I', 'B', 'K', 'R'},
                       {'R', 'K', 'A', 'U', 'L', 'H', 'I', 'S', 'P'},
                       {'S', 'A', 'D', 'I', 'Y', 'A', 'N', 'N', 'O'},
                       {'H', 'E', 'I', 'S', 'A', 'W', 'H', 'I', 'A'},
                       {'I', 'R', 'A', 'K', 'I', 'B', 'U', 'L', 'S'},
                       {'M', 'F', 'B', 'I', 'N', 'T', 'R', 'N', 'O'},
                       {'U', 'T', 'O', 'Y', 'Z', 'I', 'F', 'A', 'H'},
                       {'L', 'E', 'B', 'S', 'Y', 'N', 'U', 'N', 'E'},
                       {'E', 'M', 'O', 'T', 'I', 'O', 'N', 'A', 'L'}
                       };
stringstr[8] = {"RAKIBUL", "ANINDYA", "MOSHIUR", "SHIPLU", "KABIR", "SUNNY", "OBAIDA", "WASI"};
intmain()
{
for (inti=0; i<8; i++) {
stringstrtmp=str[i];
sort(strtmp.begin(), strtmp.end());
intlen=str[i].length();
intcnt=0;
for (intj=0; j<N; j++) {
stringtmp;
for (intk=0; k+len<=N; k++) {
tmp.clear();
for (intm=0; m<len; m++) {
tmp.append(1, table[j][k+m]);
                }
sort(tmp.begin(), tmp.end());
if (tmp==strtmp) cnt++;
            }
        }
for (intj=0; j<N; j++) {
stringtmp;
for (intk=0; k+len<=N; k++) {
tmp.clear();
for (intm=0; m<len; m++) {
tmp.append(1, table[k+m][j]);
                }
sort(tmp.begin(), tmp.end());
if (tmp==strtmp) cnt++;
            }
        }
if (cnt==2) printf("%s\n", str[i].c_str());
    }
return0;
}
目录
相关文章
|
9月前
UVa1531 - Problem Bee
UVa1531 - Problem Bee
35 0
|
7月前
|
开发框架 .NET
poj 3468 A Simple Problem with Integers线段树区间修改
题目意思很简单,有N个数,Q个操作, Q l r 表示查询从l到r 的和,C l r v 表示将从l到r 的值加上v,明显的线段树,不知道线段树的人肯定暴力,肯定超时,哈哈!!
19 0
|
9月前
|
网络架构
POJ 3250 Bad Hair Day、POJ 2796 Feel Good(单调栈)
POJ 3250 Bad Hair Day、POJ 2796 Feel Good(单调栈)
|
9月前
UVa11296 - Counting Solutions to an Integral Equation(枚举技巧)
UVa11296 - Counting Solutions to an Integral Equation(枚举技巧)
32 0
|
9月前
UVa11157 - Dynamic Frog(动态规划)
UVa11157 - Dynamic Frog(动态规划)
36 0
|
9月前
UVa10776 - Determine The Combination(有重复元素的组合问题)
UVa10776 - Determine The Combination(有重复元素的组合问题)
29 0
A. Codeforces Checking(打表枚举)
A. Codeforces Checking(打表枚举)
33 0
HDU-1048,The Hardest Problem Ever(字符串处理)
HDU-1048,The Hardest Problem Ever(字符串处理)
HDU-1002,A + B Problem II(Java大数)
HDU-1002,A + B Problem II(Java大数)