标签:
http://acm.hdu.edu.cn/showproblem.php?pid=1285
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18484 Accepted Submission(s): 7399
两个字, 不会, 等我什么时候懂拓扑的时候, 我再把这两个字给删了
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define N 550
int v[N][N], s[N];
void Put(int n)
{
int i, j, k;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(s[j]==0)
{
s[j]--;
if(i==n) printf("%d\n", j);
else printf("%d ", j);
for(k=1; k<=n; k++)
{
if(v[j][k])
{
s[k]--;
}
}
break;
}
}
}
int main()
{
int n, m;
while(scanf("%d%d", &n, &m)!=EOF)
{
int i, a, b;
memset(v, 0, sizeof(v));
memset(s, 0, sizeof(s));
for(i=1; i<=m; i++)
{
scanf("%d%d", &a, &b);
if(!v[a][b])
{
v[a][b] = 1;
s[b]++;
}
}
Put(n);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/YY56/p/5022255.html