1.2.2 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

@[email protected]

---

@@-

@[email protected]

@--

[email protected]

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

代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <algorithm>
 5 using namespace std;
 6 int main()
 7 {
 8     freopen("transform.in","r",stdin);
 9     freopen("transform.out","w",stdout);
10     int n;
11     char a[11][11],b[11][11],c;
12     bool mar[10];
13     memset(mar,true,sizeof(mar));
14     cin>>n;
15     getchar();
16     for(int i=1;i<=n;i++){
17         for(int j=1;j<=n;j++){
18             cin>>a[i][j];
19             b[i][n+1-j]=a[i][j];
20         }
21         getchar();
22     }
23     for(int i=1;i<=n;i++){
24         for(int j=1;j<=n;j++){
25             cin>>c;
26             if(c!=a[n+1-j][i]) mar[1]=false;//90
27             if(c!=a[n+1-i][n+1-j]) mar[2]=false;//180
28             if(c!=a[j][n+1-i]) mar[3]=false;//270
29             if(c!=b[i][j]) mar[4]=false;//水平翻转
30             if(c!=b[n+1-j][i]) mar[5]=false;//水平翻转+90
31             if(c!=b[n+1-i][n+1-j]) mar[6]=false;//水平翻转+180
32             if(c!=b[j][n+1-i]) mar[7]=false;//水平翻转+270
33             if(c!=a[i][j]) mar[8]=false;//不改变
34         }
35         getchar();
36     }
37     int f=0;
38     for(int i=1;i<=4;i++){
39         if(mar[i]&&!f) {f=1;cout<<i<<endl;}
40     }
41     if((mar[5]||mar[6]||mar[7])&&!f) {f=1;cout<<5<<endl;}
42     if(mar[8]&&!f) {f=1;cout<<6<<endl;}
43     if(!f) cout<<7<<endl;
44     return 0;
45 }
时间: 2024-12-24 02:03:31

1.2.2 Transformations的相关文章

SSIS 阻塞,半阻塞和全阻塞 (Non-blocking, semi-blocking and Fully-blocking) transformations清单

三种Blocking类型,这里跟数据流的Buff关系很大:■■ non-blocking transformations,每一行直接转换输出,没有等待.■■ partial-blocking transformation,直到存储一定数量的好才输出.■■ blocking transformation, 在输出前必须先读入所有行. Logical Row-Level Transformations Data   flow transformation purpose blocking type

Spark1.1.0 Transformations

Transformations The following table lists some of the common transformations supported by Spark. Refer to the RDD API doc (Scala, Java, Python) and pair RDD functions doc (Scala, Java) for details. Transformation Meaning map(func) Return a new distri

微软ASP.NET网站部署指南(3):使用Web.Config文件的Transformations

1. 综述 大多数程序里都会在Web.config里设置參数,而且在部署的时候须要更改. 每次都手工更改这些配置非常乏味,也easy出错. 该章节将会告诉你假设通过自己主动化更新Web.config文件来避免这些问题. 2. Web.config Transformations 与Web Deploy Parameters 有2种方式来自己主动化更新Web.config文件的设置:Web.config transformations和Web Deploy parameters. Web.conf

[Compose] 21. Apply Natural Transformations in everyday work

We see three varied examples of where natural transformations come in handy. const Right = x => ({ chain : f => f(x), ap : other => other.map(x), traverse : (of, f) => f(x).map(Right), map : f => Right(f(x)), fold : (f, g) => g(x), conca

Spark Transformations

We all know the following fact: 1, RDD are immutable 2, Never modify RDD in place 3, Transform RDD to another RDD There are 2 different transformations for RDD, one is narrow transformation: transformations like map, flatMap, filter all are narrow tr

【USACO】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

Spark IMF传奇行动第17课Transformations实战总结

今晚听了王家林老师的Spark IMF传奇行动第17课Transformations实战,作业是用SCALA写cogroup: def main(args: Array[String]): Unit = { val sc = sparkContext("Transformations") cogroupTrans(sc) sc.stop() } def cogroupTrans(sc:SparkContext): Unit ={ val stuNames = Array( Tuple2

image transformations位图转换

摘自:http://sourceforge.net/p/vector-agg/mailman/vector-agg-general/?viewmonth=200403 1 引言 采用图案填充多边形,这是一个非常有趣的话题,并且通过对多边形的仿射变换,对图案进行转换,也是一个非常有趣的问题. 2 有什么简单的方法旋转保存了char*(bits())类型的agg_render_buffer,现在我准备进行位图的渲染? 实际上,可以使用image affine transformations(一般来说

【USACO】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 l