USACO 1.2 Transformations

Transformations

A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given the following list of possible transformations:

  • #1: 90 Degree Rotation: The pattern was rotated clockwise 90 degrees.
  • #2: 180 Degree Rotation: The pattern was rotated clockwise 180 degrees.
  • #3: 270 Degree Rotation: The pattern was rotated clockwise 270 degrees.
  • #4: Reflection: The pattern was reflected horizontally (turned into a mirror image of itself by reflecting around a vertical line in the middle of the image).
  • #5: Combination: The pattern was reflected horizontally and then subjected to one of the rotations (#1-#3).
  • #6: No Change: The original pattern was not changed.
  • #7: Invalid Transformation: The new pattern was not obtained by any of the above methods.

In the case that more than one transform could have been used, choose the one with the minimum number above.

PROGRAM NAME: transform

INPUT FORMAT

Line 1:A single integer, N
Line 2..N+1:N lines of N characters (each either `@' or `-'); this is the square before transformation
Line N+2..2*N+1:N lines of N characters (each either `@' or `-'); this is the square after transformation

SAMPLE INPUT (file transform.in)

3
@-@
---
@@-
@-@
@--
--@

OUTPUT FORMAT

A single line containing the the number from 1 through 7 (described above) that categorizes the transformation required to change from the `before' representation to the `after' representation.

SAMPLE OUTPUT (file transform.out)

1

题解:模拟题

写一个旋转90度函数,和一个投影函数 其他几种情况可运用这两个函数实现

旋转90°:目标矩阵 after[j][N-i-1]=原矩阵 before[i][j] 

投影:  目标矩阵 after[i][N-j-1]=原矩阵 before[i][j]


ps:本人大三狗一枚,正在持续更新博客,文章里有任何问题,希望各位网友可以指出。若有疑问也可在评论区留言,我会尽快回复。希望能与各位网友互相学习,谢谢!

/*
ID: cxq_xia1
PROG: transform
LANG: C++
*/

#include <iostream>
#include <cstdio>
using namespace std;
const int maxn=11;
int N;
char before1[maxn][maxn],after1[maxn][maxn];

bool isSame(char before[maxn][maxn],char after[maxn][maxn])
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(before[i][j]!=after[i][j])
            {
                return false;
            }
        }
    }
    return true;
}


void clockwise_90(char before[maxn][maxn],char after[maxn][maxn])
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            after[j][N-i-1]=before[i][j];
        }
    }
}

void Reflection(char before[maxn][maxn],char after[maxn][maxn])
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            after[i][N-j-1]=before[i][j];
        }
    }
}

int solve()
{
    char wise_90[maxn][maxn],wise_180[maxn][maxn],wise_270[maxn][maxn],reflect[maxn][maxn];

    clockwise_90(before1,wise_90);
    if(isSame(after1,wise_90))
        return 1;

    clockwise_90(wise_90,wise_180);
    if(isSame(after1,wise_180))
        return 2;

    clockwise_90(wise_180,wise_270);
    if(isSame(after1,wise_270))
        return 3;

    Reflection(before1,reflect);
    if(isSame(after1,reflect))
        return 4;

    Reflection(after1,reflect);
    if(isSame(wise_90,reflect)||isSame(wise_180,reflect)||isSame(wise_270,reflect))
        return 5;

    if(isSame(before1,after1))
        return 6;

    return 7;

}

int main()
{
    freopen("transform.in","r",stdin);
    freopen("transform.out","w",stdout);
    while(cin >> N)
    {
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N;j++)
            {
                cin >> before1[i][j];
            }
        }

        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N;j++)
            {
                cin >> after1[i][j];
            }
        }
        cout <<solve()<<endl;
    }
    return 0;
}



李群的一本书,是扫描版,书的质量不错。 This book is intended for a one year graduate course on Lie groups and Lie algebras. The author proceeds beyond the representation theory of compact Lie groups (which is the basis of many texts)and provides a carefully chosen range of material to give the student the bigger picture. For compact Lie groups, the Peter-Weyl theorem, conjugacy of maximal tori (two proofs), Weyl character formula and more are covered. The book continues with the study of complex analytic groups, then general noncompact Lie groups, including the Coxeter presentation of the Weyl group, the Iwasawa and Bruhat decompositions, Cartan decomposition, symmetric spaces, Cayley transforms, relative root systems, Satake diagrams, extended Dynkin diagrams and a survey of the ways Lie groups may be embedded in one another. The book culminates in a "topics" section giving depth to the student's understanding of representation theory, taking the Frobenius-Schur duality between the representation theory of the symmetric group and the unitary groups as a unifying theme, with many applications in diverse areas such as random matrix theory, minors of Toeplitz matrices, symmetric algebra decompositions, Gelfand pairs, Hecke algebras, representations of finite general linear groups and the cohomology of Grassmannians and flag varieties.   Daniel Bump is Professor of Mathematics at Stanford University. His research is in automorphic forms, representation theory and number theory. He is a co-author of GNU Go, a computer program that plays the game of Go. His previous books include Automorphic Forms and Representations (Cambridge University Press 1997)and Algebraic Geometry (World Scientific 1998).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值