进入USACO要注册才能看题: http://train.usaco.org/usacogate
题目:【翻译版、是别处的网站】http://www.wzoi.org/usaco/13%5C408.asp
SAMPLE INPUT (file transform.in)
3
@-@
---
@@-
@-@
@--
--@
SAMPLE OUTPUT (file transform.out)
1
水题……未能一次A……而且一开始还理解错题意……悲催
/*
ID: 1006100071
PROG: transform
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <utility>
#include <iomanip>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>
using namespace std;
bool match (char a[][15], char b[][15], int n) //检查是否匹配
{
int i;
for (i = 0; i < n; i++)
if (strcmp (a[i], b[i]))
return false;
return true;
}
void copy (char a[][15], char b[][15], int n) //b复制到a
{
int i;
for (i = 0; i < n; i++)
strcpy (a[i], b[i]);
}
void _90right (char a[][15], int n) //对a进行90度右转
{
int i, j;
char b[15][15];
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
b[j][n-1-i] = a[i][j];
b[j][n] = 0;
}
}
for (i = 0; i < n; i++)
strcpy (a[i], b[i]);
}
void reflect (char a[][15], int n) //对a进行镜面反射
{
char b[15][15];
int i, j;
for (i = 0; i < n; i++)
{
for (j = n - 1; j >= 0; j--)
b[i][n-1-j] = a[i][j];
b[i][n] = 0;
}
for (i = 0; i < n; i++)
strcpy (a[i], b[i]);
}
int main()
{
/*freopen ("transform.in", "r", stdin);
freopen ("transform.out", "w", stdout);*/
char before[15][15], after[15][15], tp[15][15];
int n, i;
scanf ("%d", &n);
for (i = 0; i < n; i++)
scanf ("%s", before+i);
for (i = 0; i < n; i++)
scanf ("%s", after+i);
//**************************右转3种情况:90 180 270
copy (tp, before, n);
for (i = 1; i <= 3; i++)
{
_90right (tp, n);
if (match (tp, after, n))
{
printf ("%d\n", i);
return 0;
}
}
//**************************镜面翻转,也就是水平翻转
copy (tp, before, n);
reflect (tp, n);
if (match (tp, after, n))
{
puts ("4");
return 0;
}
//**************************镜面+旋转
copy (tp, before, n);
reflect (tp, n);
for (i = 1; i <= 3; i++)
{
_90right (tp, n);
if (match (tp, after, n))
{
puts ("5");
return 0;
}
}
//**************************本来就跟原来一样
if (match (before, after, n))
{
puts ("6");
return 0;
}
puts ("7"); //方法编号必须要从小到大一次判断,才能保证所得编号最小
return 0;
}
分享到:
相关推荐
USACO题目Transformations(方块转换)及代码解析
USACO全部译题,美国题库USACO全部译题,超经典的题目
美国著名题库USACO的经典试题,配上测试数据和pascal的std标程。祝OIers在信息竞赛的道路上能走得远
其中包含了USACO前些年的月赛试题和部分试题的数据,部分试题的详细题解,英文原题目与翻译后的题目,与题解一一对应
usaco 合集,包括英文原题和中文译题,测试数据以及答案,很全啊!usaco 合集usaco 合集usaco 合集usaco 合集
USACO做题代码
这个是USACO题库中选出来的一些题,覆盖了多方面的知识点,利于锻炼C++学者的算法,里面还有部分题解
仅提供usaco 2006 mar 数据,2006其它时间网上很多。美国著名题库USACO的经典试题,祝OIers在信息竞赛的道路上能走得远
USACO月赛的金组题目,从2000-2009 , 全中文翻译。
数据结构机考所参考的USACO网站所有题目的解题思路,资源比较稀有!
pku acm上的一系列usaco题目都可以在这里找到测试数据以及源代码,不过题目的名字和pku上有得有点出入,需要自己去比较一下,2002年
USACO 官网第一到 五章 练习题中文语言官方数据 fps格式支持导入所有OJ 1 [1.1] 你的飞碟在这儿 Your Ride Is Here 2 [1.1] 贪婪的送礼者Greedy Gift Givers 3 [1.1] 黑色星期五Friday the Thirteenth 4 [1.1] 坏掉...
含2001~2017全部比赛赛题测试...2001~2007 数据√ 题面× 标程题解× 2008~2010 数据√ 题面√ 标程题解× 2011~2017 数据√ 题面√ 标程题解√ 其中除2008~2010外其他年份均按照年度、月度、金银铜白金组别整理完全
usaco历年测试数据
USACO题集及答案
USACO的一些题目代码和月赛十年题典,以及部分题解
USACO所有题目的题解 NOCOW整理版
USACO题解及中文译题1.1.1-2.4.5 题目为TXT格式文档,代码为C++语言所编写
usaco 2010-2011 nov news,喜欢usaco的朋友可以看看