###### zoj 3583 simple path

Simple Path

Time Limit: 2 Seconds      Memory Limit: 65536 KB

A path with no repeated vertices of an undirected graph is called a simple path. Given an undirected graph and two verteices S and D, return the number of vertics which don't lie on any simple paths between S and D.

#### Input

The input contains multiple test cases.

Each case starts with a line of four integers, N(1 < N ≤ 100), M(1 ≤ M ≤ N(N - 1) / 2), S(0 ≤ S < N), D(0 ≤ D < N). N is the number of vertices, M is the number of edges, S and D are two different vertices. Then M lines follow, each line contains two different integers A(0 ≤ A < N) and B(0 ≤ B < N), which represents an edge of the graph. It's ensure that there is at least one simple path between S and D.

#### Output

Output the number of such vertics, one line per case.

#### Sample Input

4 3 0 2
0 1
1 2
1 3
4 4 0 2
0 1
1 2
1 3
2 3


#### Sample Output

1
0


Author: LIU, Yaoting
Contest: ZOJ 10th Anniversary Contest

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define debug_printf(...) printf(__VA_ARGS__)
#else
#define debug_printf(...) 0
#endif

const int MAXN = 100;

bool hidden[MAXN];

void bfs(int src, int d[])
{
memset(d, -1, sizeof(*d) * MAXN);

d[src] = 0;

std::queue<int> que;
que.push(src);

while (! que.empty()) {

int v = que.front();
que.pop();

if (hidden[v]) {
continue;
}

assert(0 <= v && v < adj.size());

for (int i=0; i<adj[v].size(); ++i) {
int a = adj[v][i];
if (d[a] == -1 && !hidden[a]) {
d[a] = d[v] + 1;
que.push(a);
}
}
}
}

void solve()
{
int vertices;
int edges;
int src;
int dest;

if (scanf("%d%d%d%d", &vertices, &edges, &src, &dest) == EOF) {
exit(0);
}

for (int i=0; i<edges; ++i) {
int a = 0, b = 0;
scanf("%d%d", &a, &b);
assert(0 <= a && a < adj.size());
assert(0 <= b && b < adj.size());

}

}
}

bool onceUncovered[MAXN];
memset(onceUncovered, 0, sizeof(onceUncovered));

memset(hidden, 0, sizeof(hidden));

int d[MAXN];
int e[MAXN];

for (int i=0; i<vertices; ++i) {
if (i == dest || i == src) {
//continue;
}

hidden[i] = true;

bfs(src, d);
bfs(dest, e);

for (int v=0; v<vertices; ++v) {
if (d[v] == -1 && e[v] == -1 && v != i && v != src && v != dest) {
onceUncovered[v] = true;
}
}

hidden[i] = false;
}

int answer = 0;
for (int i=0; i<vertices; ++i) {
if (onceUncovered[i] && i != src && i != dest) {
}
}

}

int main()
{
while(true) {
solve();
}
}

#### zoj 3583 Simple Path

2012-10-05 10:21:25

#### zoj 3583 Simple Path

2012-03-13 19:51:11

#### zoj 3212 K-Nice

2013-03-21 22:00:24

#### ZOJ3202-Second-price Auction

2017-04-12 21:55:55

#### POJ 2871 A Simple Question of Chemistry（水~）

2015-08-29 08:27:55

#### ZOJ 3212 K-Nice

2015-02-25 00:20:20

#### bzoj3583 杰杰的女性朋友

2017-05-08 11:41:06

#### 【风宇冲】Unity3D教程宝典之路径搜寻：第二讲SimplePath详细教程

2014-03-10 12:22:49

#### POJ 2601 Simple calculations 利用单调性，二分找出答案

2012-06-25 16:20:14

#### ZOJ解题报告ZOJ解题报告

2010年08月02日 282KB 下载

## 不良信息举报

zoj 3583 simple path