日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

USACO SECTION 1.1.2 Transformations 爆搜

發布時間:2023/12/20 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 USACO SECTION 1.1.2 Transformations 爆搜 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  題目鏈接:?http://train.usaco.org/usacoprob2?a=f6bhTTJaVRy&S=transform

  題目大意: 給你一個初始矩陣和一個目的矩陣, 還有幾種操作, 輸出最小的操作號。

  解題思路: 有個坑就是不應該直接判等, 因為要輸出最小的操作號, 有可能就是旋轉一下也可以得到原圖形那么輸出的就不是6了, 然后就是怎么旋轉這個矩形, 想了好久然后想錯了.....不說了, 上代碼吧。

  代碼:?

/*ID: wl199701PROG: transformLANG: C++*/ #include <iostream> #include <cstring> #include <cstdio> #include <string> #include <fstream> #include <iterator> #include <map> #include <algorithm> using namespace std;int n; const int maxn = 15;struct node {char a[maxn][maxn];node() {memset(a, 0, sizeof(a));} }; node st, des;node rnode() {node temp;for( int i = 1; i <= n; i++ ) {for( int j = 1; j <= n; j++ ) {cin >> temp.a[i][j];}}return temp; }int ok( node n1, node n2 ) {for( int i = 1; i <= n; i++ ) {for( int j = 1; j <= n; j++ ) {if( n1.a[i][j] != n2.a[i][j] ) return 0;}}return 1; }void debug( node nd ) {for( int i = 1; i <= n; i++) {for( int j = 1; j <= n; j++ ) {cout << nd.a[i][j];}cout << endl;} }node change(node ori, int op) {node temp;for( int i = 1; i <= n; i++ ) {for( int j = 1; j <= n; j++ ) {switch (op) {case 1:temp.a[i][j] = ori.a[n-j+1][i];break;case 2:temp.a[i][j] = ori.a[n+1-i][n+1-j];break;case 3:temp.a[i][j] = ori.a[j][n-i+1];break;case 4:temp.a[i][j] = ori.a[i][n+1-j];break;}}}return temp; }int main(){freopen("transform.in","r",stdin);freopen("transform.out","w",stdout);while( scanf( "%d", &n ) == 1 ) {node a, b;a = rnode();b = rnode(); // node temp = change(a, 1); // debug(temp);int flag = 0;int i;for( i = 1; i <= 4; i++ ) {node temp;temp = change(a, i);if( ok( temp, b ) ) {flag = 1;cout << i << endl;break;}}if( !flag ) {node temp = change( a, 4 );for( int j = 1; j <= 3; j++ ) {node temp1 = change(temp, j);if( ok( temp1, b ) ) {flag = 1;cout << "5" << endl;break;}}}if( !flag ) {if( ok( a, b ) ) {cout << "6" << endl;continue;}}if( !flag ) {cout << "7" << endl;}}return 0; } View Code

  思考: 自己的抽象思維能力還是太弱, 自己的代碼能力還是太弱, 所以說還要加強, 另外今天該找丁濛了。

轉載于:https://www.cnblogs.com/FriskyPuppy/p/6950322.html

總結

以上是生活随笔為你收集整理的USACO SECTION 1.1.2 Transformations 爆搜的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。