Hdu 1285 determines the competition ranking (topological sorting)
Determine competition rankingsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 12152 Accepted Submission (s): 4840
The topological sorting template uses the inbound value (the end point of each edge is called the inbound value, indicating the number of times the vertex serves as the end point of the edge) to determine the position of each contestant.
# Include
# Include
Using namespace std; int team [505], len [505], child [505] [505]; // team records two child records (contestant ranking) int main () {int a, B, n, m, I, count, min; while (~ Scanf ("% d", & n, & m) {count = 0; for (I = 1; I <= n; I ++) // initialize {team [I] = 0; len [I] = 0;} while (m --) {scanf ("% d", &, & B); team [B] ++; child [a] [len [a] ++] = B; // build the contact between each vertex} while (count! = N) {if (count) printf (""); min = 501; for (I = 1; I <= n; I ++) // find a point with zero entry/exit (0 indicates that the contestant has not lost) {if (team [I] = 0 & I