题意:给出每两个队伍的胜负关系,求排名。
思路:裸裸的拓扑排序。
#include#include #include using namespace std;int n,m,p1,p2;int indegree[500010],match[505][505],flag;void tuopu(){ int i,j,k,flag=0; for(j=1;j<=n;j++) for(i=1;i<=n;i++) { if(indegree[i]==0) { if(flag==0) printf("%d",i),flag++; else printf(" %d",i); indegree[i]=-1; for(k=0;k<=n;k++) { if(match[i][k]==1) indegree[k]--; } break;//一定要break掉 } } printf("\n");}int main(){ int i,j,k; while(scanf("%d%d",&n,&m)!=EOF) { memset(match,0,sizeof(match)); memset(indegree,0,sizeof(indegree)); for(i=0;i