Dice(BFS)

Dice

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1109    Accepted Submission(s): 584


Problem Description
There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A. Similarly, consider b1.b2,b3,b4,b5,b6 to be numbers on specific faces of dice B. It’s guaranteed that all numbers written on dices are integers no smaller than 1 and no more than 6 while ai ≠ aj and bi ≠ bj for all i ≠ j. Specially, sum of numbers on opposite faces may not be 7.

At the beginning, the two dices may face different(which means there exist some i, ai ≠ bi). Ddy wants to make the two dices look the same from all directions(which means for all i, ai = bi) only by the following four rotation operations.(Please read the picture for more information)


Now Ddy wants to calculate the minimal steps that he has to take to achieve his goal.
 

 

Input
There are multiple test cases. Please process till EOF.

For each case, the first line consists of six integers a1,a2,a3,a4,a5,a6, representing the numbers on dice A.

The second line consists of six integers b1,b2,b3,b4,b5,b6, representing the numbers on dice B.
 

 

Output
For each test case, print a line with a number representing the answer. If there’s no way to make two dices exactly the same, output -1.
 

 

Sample Input
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 5 6 4 3
1 2 3 4 5 6
1 4 2 5 3 6
 

 

Sample Output

 

0
3
-1

 

      题意:

      给出两个骰子 A 和 B,分别给出六个面的数字,有向左转,向右转,向前转,向后转四种操作,问最少几步能转到相同,输出步数,如果无论如何都不可能则输出 -1。

 

      思路:

      BFS。表示出 4 种转的状态即可,白痴错误 WA 了两次。

 

       AC:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

typedef struct {
    int ans[10];
    int step, l_t, r_t, b_t, f_t;
} state;

int fin[10], num[10];

void Left (int *a) {
    int b[10];
    for (int i = 1; i <= 6; ++i) {
        b[i] = a[i];
    }
    a[1] = b[4], a[2] = b[3], a[3] = b[1];
    a[4] = b[2], a[5] = b[5], a[6] = b[6];
}

void Right (int *a) {
    int b[10];
    for (int i = 1; i <= 6; ++i) {
        b[i] = a[i];
    }
    a[1] = b[3], a[2] = b[4], a[3] = b[2];
    a[4] = b[1], a[5] = b[5], a[6] = b[6];
}

void Front (int *a) {
    int b[10];
    for (int i = 1; i <= 6; ++i) {
        b[i] = a[i];
    }
    a[1] = b[6], a[2] = b[5], a[3] = b[3];
    a[4] = b[4], a[5] = b[1], a[6] = b[2];
}

void Back (int *a) {
    int b[10];
    for (int i = 1; i <= 6; ++i) {
        b[i] = a[i];
    }
    a[1] = b[5], a[2] = b[6], a[3] = b[3];
    a[4] = b[4], a[5] = b[2], a[6] = b[1];
}

bool test1 () {
    int tt[10][10];

    memset(tt, 0, sizeof(tt));
    for (int i = 2; i <= 6; i += 2) {
        tt[ num[i - 1] ][ num[i] ] = 1;
        tt[ num[i] ][ num[i - 1] ] = 1;
    }

    for (int i = 2; i <= 6; i += 2) {
        if (!tt[ fin[i - 1] ][ fin[i] ]) return false;
        if (!tt[ fin[i] ][ fin[i - 1] ]) return false;
    }

    return true;
}

bool test2 (int *a) {
    for (int i = 1; i <= 6; ++i) {
        if (a[i] != fin[i]) return false;
    }

    return true;
}

int bfs () {
    state a;
    for (int i = 1; i <= 6; ++i) {
        a.ans[i] = num[i];
    }
    a.l_t = a.r_t = a.f_t = a.b_t = 0;
    a.step = 0;

    queue<state> q;
    q.push(a);

    while (!q.empty()) {

        state now = q.front(); q.pop();

        if (test2(now.ans)) return now.step;

        state b;
        b.step = now.step + 1;

        if (now.l_t < 3) {
            for (int i = 1; i <= 6; ++i) {
                b.ans[i] = now.ans[i];
            }
            Left(b.ans);
            b.b_t = now.b_t;
            b.f_t = now.f_t;
            b.r_t = now.r_t;
            b.l_t = now.l_t + 1;
            q.push(b);
        }

        if (now.r_t < 3) {
            for (int i = 1; i <= 6; ++i) {
                b.ans[i] = now.ans[i];
            }
            Right(b.ans);
            b.l_t = now.l_t;
            b.b_t = now.b_t;
            b.f_t = now.f_t;
            b.r_t = now.r_t + 1;
            q.push(b);
        }

        if (now.f_t < 3) {
            for (int i = 1; i <= 6; ++i) {
                b.ans[i] = now.ans[i];
            }
            Front(b.ans);
            b.b_t = now.b_t;
            b.l_t = now.l_t;
            b.r_t = now.r_t;
            b.f_t = now.f_t + 1;
            q.push(b);
        }

        if (now.b_t < 3) {
            for (int i = 1; i <= 6; ++i) {
                b.ans[i] = now.ans[i];
            }
            Back(b.ans);
            b.l_t = now.l_t;
            b.f_t = now.f_t;
            b.r_t = now.r_t;
            b.b_t = now.b_t + 1;
            q.push(b);
        }
    }

    return -1;
}

int main() {

    while (~scanf("%d", &num[1])) {

        for (int i = 2; i <= 6; ++i)
            scanf("%d", &num[i]);

        for (int i = 1; i <= 6; ++i)
            scanf("%d", &fin[i]);

        if (!test1()) printf("-1\n");
        else printf("%d\n", bfs());

    }

    return 0;
}

 

 

 

我现在想开发一个深度学习骨增量诊断及治疗方案设计的系统。实现的功能为输入患者的ct及要种植的牙位后,医生通过可视化工具移动、旋转平面,确认咬合平面,输出该牙位是否骨缺损,如果有,是什么类型的(按照turheyden分类和misch分类),同时提取出骨缺损牙位的颌骨骨段,对其进行数学特征的提取,将turheyden分类+misch分类+数学特征+大语言模型提取的患者病历文本信息作为输入特征,输入到训练好的知识图谱诊断模型中,得出诊断及治疗方案的规划。我对这个任务的拆解如下:1.ct的预处理及重采样,略。2.使用预训练模型对种植相关的解剖标志进行分割:上颌骨、下颌骨、32颗牙齿(各为1类)分别分割。3.使用程序统计分割出的牙齿,根据fdi牙位编码统计处缺牙的位点,输出;4.使用程序判断医生输入的位点是否属于缺牙位点,若是,则医生输入位点的邻牙(可通过代码进行判断,如13相邻的是12和14)采用轴对齐包围盒即立方体边界框(其z轴垂直于用户确认的咬合平面),从该牙齿分割掩膜中提取所有属于目标牙位的体素点,计算其最小/最大坐标值,共6个,构成bbox,再根据经验值对不同的牙位施加不同的扩散范围。对骨缺损位点近中、远中两个相邻牙位进行均此操作后去除bbox内的像素点及其掩膜,再对剩余像素执行“去除不相接的部分”,保留下骨缺损骨段(我有此想法是因为geomagic等软件有此类操作,但是再这个程序中去除不相接的部分不是手动而是自动,那么如何判断剩余三段骨哪个是骨缺损骨段?这是个问题)。5.turheyden分类模型:对分割出的骨缺损骨段识别其turheyden分类,此为一个识别任务,医生手动标注其属于哪一类。6.misch分类:基于分割出的骨段的hu值进行分割,若有已有算法则按照已有算法,没有则再进行一个识别任务。7.数学特征提取:对分割出的骨段提取数学特征,如几何、拓扑学特征。8.文本处理:Biobert提取病历中的关键实体 9.知识图谱构建:将两种分类信息、文本、数学特征、患者的治疗方案信息通过关系抽取模型进行图谱融合,采用Neo4j+pytorch geometric实现实时图谱动态更新。请分析我整个架构的合理性,并给出一个你认为最优的现实方案。并且我在其中也提到了一些问题,请解决或告诉我该去查找哪些东西 请用自然语言回答而非代码
03-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值