http://acm.hdu.edu.cn/showproblem.php?pid=1285
determine the position of the match
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 18484 Accepted Submission (s): 7399
problem DescriptionThere are N teams (1<=n<=500), numbered three-in-one, .... , N to play, after the game, the Referee Committee will be all the teams from the arrival of the ranking, but now the referee committee can not directly get each team's performance, only know the results of each game, that is, P1 win P2, with P1,p2 said, ranked P1 before P2. Now ask you to compile the program to determine the rankings.
Inputthe input has several groups, the first behavior in each group is two number n (1<=n<=500), M, where n represents the number of troops, and m indicates the input data for the M row. In the next M-row data, there are also two integers per line p1,p2 means that the P1 team won the P2 team.
Outputgive a ranking that meets the requirements. There is a space between the queue numbers at the time of the output, and no space after the last.
Other Notes: Qualifying rankings may not be unique, at which point the output is required to be numbered in front of the team; the input data is guaranteed to be correct, i.e. the input data ensures that there must be a qualifying ranking.
Sample Input4 31 22 34 3
Sample Output1 2 4 3
Two words, no, when I understand the topology, I have to delete the two words
#include <iostream>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespacestd;#defineN 550intV[n][n], s[n];voidPut (intN) { intI, 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); Elseprintf"%d", J); for(k=1; k<=n; k++) { if(V[j][k]) {S[k]--; } } Break; } }}intMain () {intN, M; while(SCANF ("%d%d", &n, &m)! =EOF) { intI, 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;}
(topology) determine the tournament position--hdu--1285