麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

HDU 5983 Pocket Cube (簡單模擬)

2019-11-11 05:07:58
字體:
來源:轉載
供稿:網友

大體題意:

給你一個2*2*2的魔方,問你能否一步到達各個面的顏色完全一樣。

思路:

其實挺簡單的,題意已經給足了提示,已經告訴你了魔方怎么進行標號。(就是那個圖)

只要給魔方標號,怎么轉就很簡單了,可以預處理一個b 數組和c 數組,分別是魔方轉一個面時候的側面的八個面和上面的四個面,循環賦值即可。

這樣 寫好循環賦值函數后,轉六個面只需要更改b數組和c數組即可。

詳細見代碼:

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[25];bool ok;int ori[25];void fuyuan(){    for (int i = 0; i < 24; ++i) a[i] = ori[i];}bool check(){    for (int i = 0; i < 24; i += 4){        for (int j = i; j < i+4; ++j){            if (a[j] != a[i]) return false;        }    }    return true;}int b[] = {14,15,20,22,5,4,19,17};int c[] = {2,3,1,0};void zhuan(){    int t1 = a[b[0]], t2 = a[b[1]];    for (int i = 0; i < 6; i += 2){        int id1 = b[i], id2 = b[i+1];        int nid1 = b[i+2], nid2 = b[i+3];        a[id1] = a[nid1];        a[id2] = a[nid2];    }    a[b[6] ] = t1; a[b[7] ] = t2;    if (check()) ok = 1;fuyuan();    t1 = a[b[7]], t2 = a[b[6]];    for (int i = 7; i > 2; i -= 2){        int id1 = b[i], id2 = b[i-1];        int nid1 = b[i-2], nid2 = b[i-3];        a[id1] = a[nid1];        a[id2] = a[nid2];    }    a[b[0] ] = t2; a[b[1] ] = t1;    if (check()) ok = 1; fuyuan();}void add(int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int c0,int c1,int c2,int c3){    b[0] = a0;b[1] = a1;b[2] = a2;b[3] = a3;b[4] = a4;b[5] = a5;b[6] = a6;b[7] = a7;    c[0] = c0;c[1] = c1;c[2] = c2;c[3] = c3;}void up(){    add(14,15,20,22,5,4,19,17,2,3,1,0);    zhuan();}void down(){    add(12,13,21,23,7,6,18,16,8,9,11,10);    zhuan();}void Left(){    add(2,0,14,12,10,8,6,4,19,17,18,16);    zhuan();}void Right(){    add(3,1,15,13,11,9,7,5,20,22,23,21);    zhuan();}void qian(){    add(0,1,20,21,11,10,16,17,14,15,13,12);    zhuan();}void hou(){    add(2,3,22,23,9,8,18,19,4,5,6,7);    zhuan();}int main(){    int T;    scanf("%d",&T);    while(T--){        ok = 0;        for (int i = 0; i < 24; ++i) scanf("%d",a+i);        for (int i = 0; i < 24; ++i)ori[i] = a[i];        if (check()) ok = 1;        up(); down(); Left(); Right(); qian(); hou();        if (ok)puts("YES");        else puts("NO");    }    return 0;}

Pocket Cube

Time Limit: 2000/1000 MS (java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 358    Accepted Submission(s): 131PRoblem DescriptionThe Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik’s Cube.The cube consists of 8 pieces, all corners.Each piece is labeled by a three dimensional coordinate (h, k, l) where h, k, l ∈ {0, 1}. Each of the six faces owns four small faces filled with a positive integer.For each step, you can choose a certain face and turn the face ninety degrees clockwise or counterclockwise.You should judge that if one can restore the pocket cube in one step. We say a pocket cube has been restored if each face owns four same integers. InputThe first line of input contains one integer N(N ≤ 30) which is the number of test cases.For each test case, the first line describes the top face of the pocket cube, which is the common 2 × 2 face of pieceslabelled by (0, 0, 1),(0, 1, 1),(1, 0, 1),(1, 1, 1). Four integers are given corresponding to the above pieces.The second line describes the front face, the common face of (1, 0, 1),(1, 1, 1),(1, 0, 0),(1, 1, 0). Four integers aregiven corresponding to the above pieces.The third line describes the bottom face, the common face of (1, 0, 0),(1, 1, 0),(0, 0, 0),(0, 1, 0). Four integers aregiven corresponding to the above pieces.The fourth line describes the back face, the common face of (0, 0, 0),(0, 1, 0),(0, 0, 1),(0, 1, 1). Four integers aregiven corresponding to the above pieces.The fifth line describes the left face, the common face of (0, 0, 0),(0, 0, 1),(1, 0, 0),(1, 0, 1). Four integers are givencorresponding to the above pieces.The six line describes the right face, the common face of (0, 1, 1),(0, 1, 0),(1, 1, 1),(1, 1, 0). Four integers are givencorresponding to the above pieces.In other Words, each test case contains 24 integers a, b, c to x. You can flat the surface to get the surface developmentas follows.
+ - + - + - + - + - + - +| q | r | a | b | u | v |+ - + - + - + - + - + - +| s | t | c | d | w | x |+ - + - + - + - + - + - +        | e | f |        + - + - +        | g | h |        + - + - +        | i | j |        + - + - +        | k | l |        + - + - +        | m | n |        + - + - +        | o | p |        + - + - + OutputFor each test case, output YES if can be restored in one step, otherwise output NO. Sample Input
41 1 1 12 2 2 23 3 3 34 4 4 45 5 5 56 6 6 66 6 6 61 1 1 12 2 2 23 3 3 35 5 5 54 4 4 41 4 1 42 1 2 13 2 3 24 3 4 35 5 5 56 6 6 61 3 1 32 4 2 43 1 3 14 2 4 25 5 5 56 6 6 6 Sample Output
YESYESYESNO Source2016ACM/ICPC亞洲區青島站-重現賽(感謝中國石油大學) Recommendjiangzijing2015   |   We have carefully selected several similar problems for you:  6014 6013 6012 6011 6010  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲男人一区 | 香蕉国产在线视频 | 中文字幕在线观看精品 | 91亚洲免费视频 | 九艹在线 | 亚洲一区二区三区在线免费观看 | 久久国产精品免费视频 | 另类亚洲孕妇分娩网址 | a一级黄| 午夜视频观看 | 欧美激情精品久久久久久久久久 | 久久污 | 国产一级aa大片毛片 | 99国产精品国产免费观看 | 国产亚洲精品久久久久久久软件 | 国产在线一区二区三区 | 国产精品久久久久久久久久尿 | 国产手机国产手机在线 | 中文字幕在线亚洲精品 | 91丨九色丨国产在线观看 | 一级毛片在线视频 | h视频免费在线观看 | free korean xxxxhd| 中文字幕网在线 | 伊人在线视频 | 一级在线| 欧美一级片一区 | 久久精品欧美一区 | 免费专区 - 91爱爱 | 1314av| 一级精品| 88xx成人永久免费观看 | 精品久久久久久综合日本 | 久久久久亚洲视频 | 成人超碰 | 中国女警察一级毛片视频 | hdbbwsexvideo | 国产91极品 | 欧美性生活久久久 | 韩国精品一区二区三区四区五区 | 久久草在线视频 |