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

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

HDU 5983 Pocket Cube (簡單模擬)

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

大體題意:

給你一個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  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙的两根好大拔不出去h | 久草手机在线观看视频 | 一区二区三区无码高清视频 | 久久露脸国语精品国产91 | 91成人免费网站 | av日韩一区二区 | 中文字幕在线观看1 | 午夜精品视频免费观看 | 在线a毛片| 中文字幕四区 | 国产中文av在线 | 欧美精品一区二区性色 | 羞羞的动漫在线观看 | 亚洲精品成人18久久久久 | 91av在线免费播放 | 国产免费看 | 亚洲第一成网站 | 国产18视频 | 精品视频 久久久 | 成人毛片在线 | 91在线精品亚洲一区二区 | 久久久久免费精品 | 免费h片网站 | 精品一区二区三区在线观看视频 | xxnxx中国18| 99re色| 性爱视频在线免费 | 中文字幕在线视频网站 | 婷婷久久青草热一区二区 | 国产一区免费观看 | 久久免费视频精品 | 一级电影在线观看 | 久久免费观看一级毛片 | 色婷婷久久一区二区 | 激情夜色 | 久久久www视频 | 视频一区二区三区视频 | 欧美日韩亚洲在线 | 爽爽视频免费看 | 久久久一区二区三区视频 | 久久久新 |