# L2-013. 紅色警報

```5 4
0 1
1 3
3 0
0 4
5
1 2 0 4 3
```

```City 1 is lost.
City 2 is lost.
Red Alert: City 0 is lost!
City 4 is lost.
City 3 is lost.
Game Over.思路：點連通度，判斷是否為割點；每次判斷割點刪除前后變化，連通分支數增加則為割點。最近寫的題好像都有點兒暴力哎```
```#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int n, m;
int flag[505], vis[505], map[505][505];
void DFS(int begin)
{
vis[begin] = 1;
for (int i = 0; i < n; i++)
if (vis[i] == 0 && flag[i] == 0&&map[begin][i])
DFS(i);
}
int main()
{
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int a, b; cin >> a >> b;
map[a][b] = map[b][a] = 1;
}

int k; cin >> k;
int s, e, sum = 0;
memset(flag, 0, sizeof(flag));
memset(vis, 0, sizeof(vis));
for (int i = 0; i < n; i++)
{
if (flag[i] == 1 || vis[i] == 1)
continue;
DFS(i);
sum++;
}
s = sum;
while (k--){
int city; cin >> city;
flag[city] = 1;
sum = 0;
memset(vis, 0, sizeof(vis));
for (int i = 0; i < n; i++)
{
if (flag[i] == 1 || vis[i] == 1)
continue;
DFS(i);
sum++;
}
e = sum;

if (s >= e)
cout << "City " << city << " is lost." << endl;
else cout << "Red Alert: City " << city << " is lost!" << endl;

int sign = 0;
for (int i = 0; i < n;i++)
if (flag[i] == 1)sign++;
if (sign == n)cout << "Game Over." << endl;
s = e;
}

return 0;
}```

` `

#### 注意！

L2-013. 紅色警報（dfs） L2-013. 紅色警報 L2-013. 紅色警報 pta L2-013. 紅色警報 L2-013. 紅色警報 L2-013. 紅色警報 L2-013. 紅色警報 L2-013. 紅色警報 L2-013. 紅色警報 L2-013. 紅色警報（dfs）