比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
C |
题目名称 |
Asm.Def的游戏 |
最终得分 |
0 |
用户昵称 |
VG|Kn. |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2015-10-31 11:26:52 |
显示代码纯文本
#include<iostream>
#include<cstring>
using namespace std;
const long maxn = 20000 + 100;
const long maxm = 500000 + 100;
int g[maxn][maxn];
int n, m, count, z, ans;
int u[maxm], v[maxm], a[maxn];
void fun()
{
memset(a, 0, sizeof(a));
for (int i =1; i <= n; i++)
{
count = 0;
for (int j = 1; j <= n; j++)
{
if (g[i][j] == 1)
count++;
}
if (count >= 3)
a[i] = 1;
}
}
int main()
{
freopen("asm_game.in","r",stdin);
freopen("asm_game.out","w",stdout);
memset(g, 0, sizeof(g));
cin >> n >> m;
int cnt = n;
for (int i = 1; i <= m; i++)
{
cin >> u[i] >> v[i];
g[u[i]][v[i]] = 1;
g[v[i]][u[i]] = 1;
}
fun();
for (int i = 1; i <= n; i++)
{
z = 0;
if (a[i] == 1)
z++;
else
{
for (int j = 1; j <= n; j++)
{
g[i][j] = 0;
g[j][i] = 0;
}
cnt--;
}
if (z != cnt || cnt != 0)
fun();
else
break;
}
if (cnt == 0)
ans = 0;
else
for (int i = n; i >= 1; i--)
{
if (a[i] == 1)
{
ans = i;
break;
}
else
continue;
}
cout << ans;
return 0;
}