挺有趣的一道题,呵呵,不算难

/*
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的更多相关文章

  1. USACO Section 1.2 Transformations 解题报告

    题目 题目描述 一块 N x N正方形的黑白瓦片的图案要被转换成新的正方形图案. 写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式: 转 90 度:图案按顺时针转 90 度. 转 1 ...

  2. USACO Section 1.2PROB Miking Cows

    贪心做过去,先对每个时间的左边点进行排序,然后乱搞,当然线段树也可以做 /* ID: jusonal1 PROG: milk2 LANG: C++ */ #include <iostream&g ...

  3. 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&& ...

  4. USACO Section 3.3: Riding the Fences

    典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...

  5. USACO Section 3.3 Camlot(BFS)

    BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...

  6. [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)

    nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...

  7. 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 ...

  8. USACO Section 1.3 Prime Cryptarithm 解题报告

    题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...

  9. USACO Section 1.1 Your Ride Is Here 解题报告

    题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...

随机推荐

  1. [Luogu] P1441 砝码称重

    题目描述 现有n个砝码,重量分别为a1,a2,a3,……,an,在去掉m个砝码后,问最多能称量出多少不同的重量(不包括0). 题目分析 因为读错题WAWA大哭. 先dfs枚举选的砝码,满足条件时进行d ...

  2. 使用ajax出现canceled情况

    在使用ajax的时候要注意,在只定义了一个ajax请求对象的全局变量时,如果同打开发送了一个请求,但在请求还未结束时,又利用这一个全局变量发送另外一个ajax请求,就会出现某一个请求的状态码为canc ...

  3. [Python3网络爬虫开发实战] 1.5.4-RedisDump的安装

    RedisDump是一个用于Redis数据导入/导出的工具,是基于Ruby实现的,所以要安装RedisDump,需要先安装Ruby. 1. 相关链接 GitHub:https://github.com ...

  4. 零基础入门学习Python(20)--函数:内嵌函数和闭包

    知识点 global关键字 使用global关键字,可以修改全局变量: >>> count = 5 >>> def Myfun(): count = 10 prin ...

  5. 集训第四周(高效算法设计)P题 (构造题)

    Description   There are N<tex2html_verbatim_mark> marbles, which are labeled 1, 2,..., N<te ...

  6. 关于.NET玩爬虫这些事 【初码干货】

    这几天在微信群里又聊到.NET可以救中国但是案例太少不深的问题,我说.NET玩爬虫简直就是宇宙第一,于是大神朱永光说,你为何不来写一篇总结一下? 那么今天就全面的来总结一下,在.NET生态下,如何玩爬 ...

  7. JavaEE JDBC 可滚动和可更新的结果集ResultSet

    可滚动和可更新的结果集ResultSet @author ixenos 需求背景 1.对于一个只需要分析数据的程序来说,普通的ResultSet已够用 2.但如果ResultSet用于显示一张表或查询 ...

  8. boot简介

    目录 1:bootloader介绍2:如何启动一个机器3:工具 Bootloader介绍 MTK的bootloader 主要分为Pre-loader, LK. Pre-loader: 初始化PLL,U ...

  9. 重启系统media服务

    1.adb shell 执行 stop media & start media 或者stop media ; start media 2.代码里执行 import android.os.Sys ...

  10. POJ 3680_Intervals

    题意: 给定区间和该区间对应的权值,挑选一些区间,求使得每个数都不被K个区间覆盖的最大权值和. 分析: 如果K=1,即为区间图的最大权独立集问题.可以对区间所有端点排序后利用动态规划的方法,设dp[i ...