ACM: 广搜 图论题 poj 1708
来源:互联网 发布:淘宝网左轮吉他直播 编辑:程序博客网 时间:2024/05/16 14:31
Description
Starting the game the child first of all chooses three differentintegers L, K and Q within the range between 1 and N. Then heplaces one pawn into the circle number L and another one into thecircle number K, whereupon he begins to move them using thefollowing rules:
- a pawn can be moved along the line segment, if this segment hasthe same color with the circle where another pawn isplaced,
- the pawn can be moved only in the direction of the segment (allsegments are oriented),
- two pawns can never be placed in the same circle at the sametime,
- the move order is free (i.e. it is not necessary to move pawnsalternately),
- the game ends, when one of the pawns (any of the two) reachesthe last circle number Q.
You are to write a program to find out the shortest (i.e.containing a minimal number of moves) solution for this game, if itexists.
Input
Output
Sample Input
5 3 4 1
2 3 2 1 4
8
2 1 2
4 1 5
4 5 2
5 1 3
3 2 2
3 2 4
5 3 1
3 5 1
Sample Output
YES
3
题意: 现在有两个点, L,K为两个起点编号, 计算最少的移动次数到达Q点,若可以就输出YES和最少步数,
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
#define MAX 105
const int INF = (1<<29);
struct node
{
}edges[MAX*MAX];
struct node1
{
};
int N, L, K, Q, m;
int first[MAX], num;
bool vis[MAX][MAX];
int color[MAX];
int result;
inline void add(int u,int v,int co)
{
}
void read_graph()
{
}
bool bfs()
{
}
int main()
{
//
}
- ACM: 广搜 图论题 poj 1708
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 二分法 数论题 poj 1905
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 图论题 poj 3177 同 3352
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: 广搜+素数 poj 3126 (素数表…
- ACM: polay定理 数论题 poj 1286 …
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1161 (把图重建成…
- ACM: 图论题 poj 1789 (一次AC的水…
- ACM: 简单 动态规划题 toj 1509 (…
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 1161 (把图重建成…
- spark-graphx新的里程碑GraphDataFrames
- ACM: 闭包问题 图论题 (书上练习)
- ACM: 广搜 图论题 poj 1708
- ACM: 最近公共祖先问题 图论题
- ACM: 无向图的强连通分量 图论题 p…
- ACM: 浙江省赛题目 22:00 ~ 3:00 (…
- 2012年广东ACM省赛赛后总结
- ACM: 动态规划题 toj 1511
- ACM: 动态规划题 toj 1545
- ACM: 简单DP 动态规划题 toj 1547
- ACM: DP训练好题 动态规划题 poj 1…