首页 > 代码库 > USACO Section 1.2PROB Transformations
USACO Section 1.2PROB Transformations
挺有趣的一道题,呵呵,不算难
/*ID: jusonal1PROG: transformLANG: 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;}
USACO Section 1.2PROB Transformations
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。