usaco Transformations
模拟就行。注意int arr[][]二维数组在定义时是二维数组,而函数传参时是指针。这意味着memset()的不同。传参时只能当作一维逐个memset。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon;
char src[SZ][SZ],dst[SZ][SZ]; void init(char x[SZ][SZ],int n)
{
for(int i=;i<=n;++i)
{
for(int j=;j<=n;++j)cin>>x[i][j];
}
} bool same1(char x[SZ][SZ],char y[SZ][SZ],int n)
{
for(int i=;i<=n;++i)
{
for(int j=;j<=n;++j)
{
if(y[j][n-i+]!=x[i][j])return ;
}
}
return ;
} bool same2(char x[SZ][SZ],char y[SZ][SZ],int n)
{
for(int i=;i<=n;++i)
{
for(int j=;j<=n;++j)
{
if(y[n-i+][n-j+]!=x[i][j])return ;
}
}
return ;
} bool same3(char x[SZ][SZ],char y[SZ][SZ],int n)
{
for(int i=;i<=n;++i)
{
for(int j=;j<=n;++j)
{
if(y[n-j+][i]!=x[i][j])return ;
}
}
return ;
} void getsvd(char dst[SZ][SZ],char src[SZ][SZ],int n)
{
//是指针
for(int i=;i<=n;++i)
memset(dst[i],,sizeof(dst[i]));
for(int i=;i<=n;++i)
{
for(int j=;j<=n;++j)dst[i][j]=src[i][j];
}
for(int i=;i<=n;++i)
{
for(int j=;j<=n/;++j)
{
swap(dst[i][j],dst[i][n-j+]);
}
}
} bool same4(char x[SZ][SZ],char y[SZ][SZ],int n)
{
char svd[SZ][SZ];
//cout<<sizeof(svd)<<endl;
//memset(svd,0,sizeof(svd));
getsvd(svd,x,n);
//return equal(svd+2,svd+3,y+2);
//return equal(svd[1]+1,svd[1]+1+n*12,y[1]+1);
return equal(svd[]+,svd[]+n*,y[]+);
} bool same5(char x[SZ][SZ],char y[SZ][SZ],int n)
{
char svd[SZ][SZ];
getsvd(svd,x,n);
if(same1(svd,y,n))return ;
else if(same2(svd,y,n))return ;
else if(same3(svd,y,n))return ;
else return ;
} bool same6(char x[SZ][SZ],char y[SZ][SZ],int n)
{
return equal(x[]+,x[]+n*,y[]+);
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int n;
cin>>n;
init(src,n),init(dst,n);
if(same1(src,dst,n))cout<<<<endl;
else if(same2(src,dst,n))cout<<<<endl;
else if(same3(src,dst,n))cout<<<<endl;
else if(same4(src,dst,n))cout<<<<endl;
else if(same5(src,dst,n))cout<<<<endl;
else if(same6(src,dst,n))cout<<<<endl;
else cout<<<<endl;
}
return ;
}
usaco Transformations的更多相关文章
- 【USACO】Transformations(模拟)
Transformations A square pattern of size N x N (1 <= N <= 10) black and white square tiles is ...
- 【USACO】Transformations
A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into ...
- Transformations 方块转换 USACO 模拟 数组 数学 耐心
1006: 1.2.2 Transformations 方块转换 时间限制: 1 Sec 内存限制: 128 MB提交: 10 解决: 7[提交] [状态] [讨论版] [命题人:外部导入] 题目 ...
- USACO Section 1.2 Transformations 解题报告
题目 题目描述 一块 N x N正方形的黑白瓦片的图案要被转换成新的正方形图案. 写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式: 转 90 度:图案按顺时针转 90 度. 转 1 ...
- USACO 1.2.2 Transformations 方块转换
Description 一块N x N(1<=N<=10)正方形的黑白瓦片的图案要被转换成新的正方形图案.写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式: 1:转90度 ...
- USACO Section1.2 Transformations 解题报告
transform解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------ ...
- USACO Section 1.2PROB Transformations
挺有趣的一道题,呵呵,不算难 /* ID: jusonal1 PROG: transform LANG: C++ */ #include <iostream> #include <f ...
- USACO 1.2 Transformations (模拟)
模拟题目,依照题目给定的要求变换图形就可以,变换的优先级依次减小. 这个题目我写的非常乱.只是最还还是勉强能够执行 /* ID:twd30651 PROG:transform LANG:C++ */ ...
- USACO Training Section 1.2 [USACO1.2]方块转换 Transformations
题目描述 一块N x N(1<=N<=10)正方形的黑白瓦片的图案要被转换成新的正方形图案.写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式: 1:转90度:图案按顺时针 ...
随机推荐
- SVM学习笔记4-核函数和离群点的处理
核函数在svm里,核函数是这样定义的.核函数是一个n*n(样本个数)的矩阵,其中:$K_{ij}=exp(-\frac{||x^{(i)}-x^{(j)}||^{2}}{2\sigma ^{2}})$ ...
- Docker 使用Docker-Compose编排容器
简介: Docker Compose是一个用来定义和运行复杂应用的Docker工具.一个使用Docker容器的应用,通常由多个容器组成.使用Docker Compose不再需要使用shell脚本来启动 ...
- bitset,2018蓝桥杯-明码(二进制转换)
bitset可以存储二进制数位 bitset<8> x(2); cout<<x<<endl; //输出:00000010 #include <iostream ...
- 论文笔记:Learning Dynamic Memory Networks for Object Tracking
Learning Dynamic Memory Networks for Object Tracking ECCV 2018Updated on 2018-08-05 16:36:30 Paper: ...
- [echarts] - echarts量化比较图表类型解析
https://echarts.baidu.com/examples/editor.html?c=watermark <!DOCTYPE html> <!--用作两种货品的参数对比- ...
- Derek解读Bytom源码-Api Server接口服务
作者:Derek 简介 Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom ...
- AtomicReference实现单例模式
CAS是项乐观锁技术,当多个线程尝试使用CAS同时更新同一个变量时,只有其中一个线程能更新变量的值,而其它线程都失败,失败的线程并不会被挂起,而是被告知这次竞争中失败,并可以再次尝试. 乐观锁的一种实 ...
- Docker:Service
Prerequisites Install Docker version 1.13 or higher. Get Docker Compose. On Docker for Mac and Docke ...
- Echarts 设置地图大小
项目中要添加地图,默认地图太小,折腾半天终于找到解决方案. series: [ { //name: '香港18区人口密度', type: 'map', mapType: 'jiangsu', // 自 ...
- Spring依赖
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...