USACO Section 1.2PROB Transformations

挺有趣的一道题,呵呵,不算难

/*
ID: jusonal1
PROG: transform
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;
const int maxn = 15;
int n;
struct MP{
    char mp[maxn][maxn];
};
MP orign_map;
MP then_map;
MP new_map;
bool pattern_1(const MP a){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(then_map.mp[i][j] != a.mp[n-j+1][i])
                return false;
    return true;
}
bool pattern_2(const MP a){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(then_map.mp[i][j] != a.mp[n-i+1][n-j+1])
                return false;
    return true;
}
bool pattern_3(MP a){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(then_map.mp[i][j] != a.mp[j][n-i+1])
                return false;
    return true;
}
bool pattern_4(MP a){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(then_map.mp[i][j] != a.mp[i][n-j+1])
                return false;
    return true;
}
bool pattern_5(MP a){
    if(pattern_1(a)) return true;
    if(pattern_2(a)) return true;
    if(pattern_3(a)) return true;
    return false;
}
bool pattern_6(MP a){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            if(a.mp[i][j] != then_map.mp[i][j]) return false;
    return true;
}
void print(){
    for(int i = 1;i <= n;++i){
        for(int j = 1;j <= n;++j)
            printf("%c",new_map.mp[i][j]);
            puts("");
    }
    puts("");
}
void getmap(){
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
        scanf(" %c",&orign_map.mp[i][j]);
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
        scanf(" %c",&then_map.mp[i][j]);
    return ;
}
int main () {
    freopen("transform.in","r",stdin);
    freopen("transform.out","w",stdout);
    scanf("%d",&n);
    getmap();
    MP new_map;
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            new_map.mp[i][j] = orign_map.mp[i][n-j+1];
    if(pattern_1(orign_map)) puts("1");
    else if(pattern_2(orign_map)) puts("2");
    else if(pattern_3(orign_map)) puts("3");
    else if(pattern_4(orign_map)) puts("4");
    else if(pattern_5(new_map)) puts("5");
    else if(pattern_6(orign_map))puts("6");
    else puts("7");
    return 0;
}
时间: 2024-11-13 06:44:07

USACO Section 1.2PROB Transformations的相关文章

USACO Section 1.2PROB Miking Cows

贪心做过去,先对每个时间的左边点进行排序,然后乱搞,当然线段树也可以做 /* ID: jusonal1 PROG: milk2 LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <cstdio> #include <algorithm> #include <map> #include <cstring> using

USACO Section 2.1 Healthy Holsteins

/* ID: lucien23 PROG: holstein LANG: C++ */ #include <iostream> #include <fstream> #include <vector> using namespace std; bool compFun(int x, int y) { int temp, i = 0; while (true) { temp = 1 << i; if (temp&x > temp&y) {

USACO Section 2.2 Party Lamps

/* ID: lucien23 PROG: lamps LANG: C++ */ /* * 此题的技巧之处就是需要注意到任何button只要按下2的倍数次就相当于没有按 * 所以其实只需要考虑4个按钮,每个按钮是否被有效按下过一次就好 * 直接使用枚举法,一共只有2^4=16种情况 * 对于每种情况需要知道被按下的有效次数(也就是被按下过的按钮数),必须满足 * (C-有效次数)%2=0才行,这样其他次数才能视为无效 * 然后验证各种情况是否符合要求,将符合要求的情况按序输出即可 */ #inc

USACO Section 2.2 Runaround Numbers

/* ID: lucien23 PROG: runround LANG: C++ */ #include <iostream> #include <fstream> #include <cstring> using namespace std; int main() { ifstream infile("runround.in"); ofstream outfile("runround.out"); if(!infile || !

USACO Section 2.2 Preface Numbering

/* ID: lucien23 PROG: preface LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <map> using namespace std; int main() { ifstream infile("preface.in"); ofstream outfile("preface.out")

USACO Section 2.1 Sorting a Three-Valued Sequence

/* ID: lucien23 PROG: sort3 LANG: C++ */ #include <iostream> #include <fstream> #include <vector> #include <algorithm> using namespace std; void exchange(int nums[], int begin, int end, int N, int x); int sum = 0; int main() { ifst

USACO Section 1.1 Your Ride Is Here

原题: Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, how

[IOI1996] USACO Section 5.3 Network of Schools(强连通分量)

nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. ---------------------------------------------------------------------------------- #include<cstdio> #include<iostream> #include<algorithm> #includ

USACO Section 5.3 Big Barn(dp)

USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1  (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .dp(i,j)表示以坐标(i,j)为左上角的barn边长最大值,dp(i+1,j),dp(i,j+1)分别表示向右和向下能扩展的最大边长,但是以此为正方形时,右下方的一个格子没有考虑到,所以就+个dp(i+1,j+1).边界为:dp(i,j)=1(i==n-1或j==n-1). -----------