USACO Section 1.2PROB Transformations
挺有趣的一道题,呵呵,不算难
/*
ID: jusonal1
PROG: transform
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;
const int maxn = 15;
int n;
struct MP{
char mp[maxn][maxn];
};
MP orign_map;
MP then_map;
MP new_map;
bool pattern_1(const MP a){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(then_map.mp[i][j] != a.mp[n-j+1][i])
return false;
return true;
}
bool pattern_2(const MP a){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(then_map.mp[i][j] != a.mp[n-i+1][n-j+1])
return false;
return true;
}
bool pattern_3(MP a){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(then_map.mp[i][j] != a.mp[j][n-i+1])
return false;
return true;
}
bool pattern_4(MP a){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(then_map.mp[i][j] != a.mp[i][n-j+1])
return false;
return true;
}
bool pattern_5(MP a){
if(pattern_1(a)) return true;
if(pattern_2(a)) return true;
if(pattern_3(a)) return true;
return false;
}
bool pattern_6(MP a){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
if(a.mp[i][j] != then_map.mp[i][j]) return false;
return true;
}
void print(){
for(int i = 1;i <= n;++i){
for(int j = 1;j <= n;++j)
printf("%c",new_map.mp[i][j]);
puts("");
}
puts("");
}
void getmap(){
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
scanf(" %c",&orign_map.mp[i][j]);
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
scanf(" %c",&then_map.mp[i][j]);
return ;
}
int main () {
freopen("transform.in","r",stdin);
freopen("transform.out","w",stdout);
scanf("%d",&n);
getmap();
MP new_map;
for(int i = 1;i <= n;++i)
for(int j = 1;j <= n;++j)
new_map.mp[i][j] = orign_map.mp[i][n-j+1];
if(pattern_1(orign_map)) puts("1");
else if(pattern_2(orign_map)) puts("2");
else if(pattern_3(orign_map)) puts("3");
else if(pattern_4(orign_map)) puts("4");
else if(pattern_5(new_map)) puts("5");
else if(pattern_6(orign_map))puts("6");
else puts("7");
return 0;
}
USACO Section 1.2PROB Transformations的更多相关文章
- USACO Section 1.2 Transformations 解题报告
题目 题目描述 一块 N x N正方形的黑白瓦片的图案要被转换成新的正方形图案. 写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式: 转 90 度:图案按顺时针转 90 度. 转 1 ...
- USACO Section 1.2PROB Miking Cows
贪心做过去,先对每个时间的左边点进行排序,然后乱搞,当然线段树也可以做 /* ID: jusonal1 PROG: milk2 LANG: C++ */ #include <iostream&g ...
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- [模板] Treap
插入x 删除x 查询排名为x的数 查询x的排名 求x的前驱.后继 //Stay foolish,stay hungry,stay young,stay simple #include<iostr ...
- python3.x Day6 socketserver
socketserver是啥? 简化了编写网络服务器,就是对于socket的再一次封装sockerserver包含4个类可以使用:A=socketserver.TCPServer() #用于TCP/I ...
- buf.values()
buf.values() 返回:{Iterator} 创建并返回一个包含 Buffer 值(字节)的迭代器.当 Buffer 使用 for..of 声明时将自动调用该函数. const buf = B ...
- Spring核心技术(六)——Spring中Bean的生命周期
前文已经描述了Bean的作用域,本文将描述Bean的一些生命周期作用,配置还有Bean的继承. 定制Bean 生命周期回调 开发者通过实现Spring的InitializeingBean和Dispos ...
- orcad中的快捷键
在画原理图的时候,不能正常的将将要放下的器件与旁边的对其,一种解决办法是按F6,调出大的水平竖直线,在按F6,此线标消失. Ctrl+F8是全屏模式,关闭的方法暂时不知道,退出方式是点击按钮. F10 ...
- 九度oj 题目1206:字符串连接
题目1206:字符串连接 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:5117 解决:2373 题目描述: 不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来 ...
- [luoguP1042] 乒乓球(模拟)
传送门 终于过了这sb题了. 当初我连这道题都A不了(╯▔皿▔)╯ 代码 #include <cstdio> #include <iostream> #define N 100 ...
- codevs4439 YJQ Requires Food
题目描述 Description 神犇YJQ有n个不同的妹子和m种食物,每一天每一种食物只供应一个妹子吃的份量.在接下来的t天内,YJQ准备包养所有的妹子. 对于每个妹子,她在t天内都只会吃某些特定的 ...
- Jquery为DIV添加点击事件,Jquery为a标签超链接添加点击事件
<div>1</div> <div>2</div> <div>3</div> <div>4</div> ...
- Less Time, More profit 最大权闭合子图(最大流最小割)
The city planners plan to build N plants in the city which has M shops. Each shop needs products fro ...