USACO 1.2 Transformations (模拟)
模拟题目,依照题目给定的要求变换图形就可以,变换的优先级依次减小。
这个题目我写的非常乱。只是最还还是勉强能够执行
/*
ID:twd30651
PROG:transform
LANG:C++
*/
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<string.h>
using namespace std;
#define MAX 10
char a[MAX][MAX];
char b[MAX][MAX];
char c[MAX][MAX];
char t[MAX][MAX];
int N;
int flag=0;
int check()
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
if(b[i][j]!=t[i][j])return 0;
}
return 1;
}
void do1(char a[][MAX],char b[][MAX],int f)//f是个标志。标志是第五个操作调用的。还是直接调用的
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
b[j][N-i-1]=a[i][j];
}
if(!f&&check()){printf("1\n");
flag=1;
}
}
void do2(char a[][MAX],char b[][MAX],int f)//同理
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
b[N-i-1][N-j-1]=a[i][j];
}
if(!f&&check()){
printf("2\n");
flag=1;
}
}
void do3(char a[][MAX],char b[][MAX],int f)//同理
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
b[N-j-1][i]=a[i][j];
}
if(!f&&check()){
printf("3\n");
flag=1;
}
}
void do4(char a[][MAX],char b[][MAX])
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
b[i][N-j-1]=a[i][j];
}
if(check()){
printf("4\n");
flag=1;
}
}
void do5(char a[][MAX],char b[][MAX])
{
do4(a,c);
for(int i=0;i<3;++i)
{
if(i==0)
{
do1(c,b,1);
if(check()){printf("5\n");
flag=1;
}
}
else if(i==1)
{
do2(c,b,1);
if(check()){printf("5\n");
flag=1;}
}
else
{
do3(c,b,1);
if(check()){printf("5\n");
flag=1;}
}
}
}
void do6(char a[][MAX],char b[][MAX])
{
for(int i=0;i<N;++i)
for(int j=0;j<N;++j)
{
b[i][j]=a[i][j];
}
if(check())
{
printf("6\n");
flag=1;
}
} int main(int argc,char *argv[])
{
freopen("transform.in","r",stdin);
freopen("transform.out","w",stdout);
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
scanf("%d",&N);
for(int i=0;i<N;++i)
scanf("%s",a[i]);
for(int i=0;i<N;++i)
scanf("%s",t[i]);
for(int i=1;i<=7;++i)
{
switch(i)
{
case 1:
if(flag==0)
do1(a,b,0);
break;
case 2:
if(flag==0)
do2(a,b,0);
break;
case 3:
if(flag==0)
do3(a,b,0);
break;
case 4:
if(flag==0)
do4(a,b);
break;
case 5:
if(flag==0)
do5(a,b);
break;
case 6:
if(flag==0)
do6(a,b);
break;
case 7:
if(flag==0)
printf("7\n");
break;
}
}
return 0;
}
USACO 1.2 Transformations (模拟)的更多相关文章
- USACO The Tamworth Two 模拟
一道模拟题不过要担心的是牛或者人在转弯的时候,另一方如果能走,那么要走,不能停留. 还是蛮简单的. 调试输出的话可以看到具体追击过程 Source Code: /* ID: wushuai2 PROG ...
- USACO Section1.2 Transformations 解题报告
transform解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------ ...
- 【题解】Acting Cute
题目简介 正在 rainbow 的城堡游玩的 Freda 恰好看见了在地毯上跳舞卖萌的水叮当--于是-- Freda:"呜咕>_< 我也要卖萌T_T!" rainbow ...
- 【USACO】Transformations(模拟)
Transformations A square pattern of size N x N (1 <= N <= 10) black and white square tiles is ...
- Transformations 方块转换 USACO 模拟 数组 数学 耐心
1006: 1.2.2 Transformations 方块转换 时间限制: 1 Sec 内存限制: 128 MB提交: 10 解决: 7[提交] [状态] [讨论版] [命题人:外部导入] 题目 ...
- USACO 1.3... 虫洞 解题报告(搜索+强大剪枝+模拟)
这题可真是又让我找到了八数码的感觉...哈哈. 首先,第一次见题,没有思路,第二次看题,感觉是搜索,就这样写下来了. 这题我几乎是一个点一个点改对的(至于为什么是这样,后面给你看一个神奇的东西),让我 ...
- Your Ride Is Here 你的飞碟在这儿 USACO 模拟
1001: 1.1.1 Your Ride Is Here 你的飞碟在这儿 时间限制: 1 Sec 内存限制: 128 MB提交: 9 解决: 9[提交] [状态] [讨论版] [命题人:外部导入 ...
- 【USACO】Transformations
A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into ...
- USACO Runaround Numbers 模拟
根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...
随机推荐
- 解决 dotnet core 1.x 命令行(cli) 下运行路径错误
环境: Windows 10,Visual Studio 2017 centos 7,nginx,supervisor,dotnet core 1.1 问题: 在 Linux 配置 superviso ...
- [MVC.NET] Asp.Net MVC3 简单入门第一季
转自:http://www.cnblogs.com/fly_dragon/archive/2011/10/12/2208042.html 初识Asp.Net MVC2.0 初识Asp.Net MVC2 ...
- C#关于XML的一些简单用法
关于XML文件的用法,本文简单介绍创建.读取和增删操作 . 1.创建有三种方法 (1)通过XmlDocument创建,然后分级添加子目录 XmlDocument doc = new XmlDocume ...
- 机器学习——SVM讲解
支持向量机(Support Vector Machine) SVM是一类按监督学习方式对数据进行二元分类的广义线性分类器,决策边界是对学习样本求解的最大边距超平面.只需要知道,SVM是一个有监督的分类 ...
- NOIP 2013 T2 火柴排队 ---->求逆序对
[NOIP2013T2]火柴排队 背景 noip2013day1 描述 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度. 现在将每盒中的火柴各 自 排成一列, 同一列火柴的高度互不相同, ...
- B - Soldier and Bananas
Problem description A soldier wants to buy w bananas in the shop. He has to pay k dollars for the fi ...
- Codeforces Round #454
Masha and Bears Tic-Tac-Toe Shockers Seating of Students Party Power Tower Reverses
- wppay免登录付费查看隐藏内容/付费资源下载
WPPAY是一款模板兔开发的免登录的付费查看内容/付费下载资源WordPress插件,WPPAY不需要用户注册登录即可支付查看隐藏内容,把整个流程做到极简.发布文章时要隐藏的内容可以利用短代码: [w ...
- 第一课 导入库 - 创建数据集 - CSV读取 - 导出 - 查找最大值 - 绘制数据
第1课 创建数据 - 我们从创建自己的数据集开始分析.这可以防止阅读本教程的最终用户为得到下面的结果而不得不下载许多文件.我们将把这个数据集导出到一个文本文件中,这样您就可以获得从文本文件中一些拉取数 ...
- params可变参数、SqlCommand.Parameters.add()方法
namespace params可变参数{ class Program { static void Main(string[] args) { int[] num = {66,99,55,44, }; ...