国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

HDU 5983 Pocket Cube (簡單模擬)

2019-11-11 04:38:03
字體:
供稿:網(wǎng)友

大體題意:

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

思路:

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

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

這樣 寫好循環(huán)賦值函數(shù)后,轉(zhuǎn)六個面只需要更改b數(shù)組和c數(shù)組即可。

詳細見代碼:

#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亞洲區(qū)青島站-重現(xiàn)賽(感謝中國石油大學(xué)) Recommendjiangzijing2015   |   We have carefully selected several similar problems for you:  6014 6013 6012 6011 6010  


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 汨罗市| 长葛市| 科技| 德江县| 陆川县| 翼城县| 东明县| 乡城县| 任丘市| 龙南县| 江都市| 福海县| 台东县| 临武县| 门头沟区| 湘潭县| 建阳市| 正镶白旗| 安福县| 贵南县| 广安市| 响水县| 柳州市| 墨玉县| 沈阳市| 芜湖市| 闽清县| 莲花县| 安庆市| 满洲里市| 慈溪市| 时尚| 泽州县| 嘉峪关市| 晋宁县| 连山| 神木县| 屏边| 正安县| 石首市| 丹棱县|