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求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- vijos1382寻找主人
题目大意: 给出两个串(长度<=1e6),问是否同构,如果同构输出最小表示. 题解: 这是最小表示法模板题.在这里好好讲一下最小表示法. 首先有一个最暴力的方法:把所有表示搞出来排序. 时间复杂 ...
- [Python3网络爬虫开发实战] 1.8.1-pyspider的安装
pyspider是国人binux编写的强大的网络爬虫框架,它带有强大的WebUI.脚本编辑器.任务监控器.项目管理器以及结果处理器,同时支持多种数据库后端.多种消息队列,另外还支持JavaScript ...
- jQuery对table排序
<script> //col对应列,cmp两数比较方法,返回值为TRUE,FALSE function sort(col, cmp) { var table = $("#test ...
- 《机器学习实战》-逻辑(Logistic)回归
目录 Logistic 回归 本章内容 回归算法 Logistic 回归的一般过程 Logistic的优缺点 基于 Logistic 回归和 Sigmoid 函数的分类 Sigmoid 函数 Logi ...
- MapReduce架构与执行流程
一.MapReduce是用于解决什么问题的? 每一种技术的出现都是用来解决实际问题的,否则必将是昙花一现,那么MapReduce是用来解决什么实际的业务呢? 首先来看一下MapReduce官方定义: ...
- 【HDU 2196】 Computer (树形DP)
[HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...
- UART整理
通用异步收发器简称UART,英文全称"Universal Asynchronous Receiver Transmitter".UART使用标准的TTL/CMOS逻辑电平(0~5V ...
- 使用C++调用pytorch模型(Linux)
前言 模型转换思路通常为: Pytorch -> ONNX -> TensorRT Pytorch -> ONNX -> TVM Pytorch -> 转换工具 -> ...
- Android 笔记一:线性布局
建立布局 新建项目后,在如图路径下新建xml文件可以开始编辑 weight的使用 android:layout_width="0dp",或android:layout_width= ...
- mysql启服务的时候报1067错误解决办法
网上百度了半天没有有效的办法,推荐一个万能的办法: 1.看日志: mysql安装目录下 data文件 -> 后缀为.err 的文件就是日志文件 打开它 : 可以看到错误信息 2.看错 ...