title link : http://poj.org/problem?id=3660
Test Instructions:n Bull races, there are M games, 22 matches, the front is the winner. Ask you to confirm the rank of a few cows.
The first thing to do : to introduce something, to pass the closure, it can determine the relationship between as many elements as possible.
Then back to this question, how can confirm the position of the cow, that is, whether it wins or loses can deduce the other n-1 cow and its relationship. Specific ideas to see the code. QWQ
Code:
1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <iostream>5 using namespacestd;6 7 Const intMAXN = the;8 Const intINF =1e9;9 intn,m;Ten intMP[MAXN][MAXN]; One A voidFloyd () { - for(intK =1; K <= N; k++){ - for(inti =1; I <= N; i++){ the for(intj =1; J <= N; j + +){ - if(Mp[i][j] = =1|| (Mp[i][k] = =1&& Mp[k][j] = =1) ){ -MP[I][J] =1; - } + } - } + } A at } - - intMain () { -Cin>>n>>m; - for(inti =1; I <= m; i++){ - intx, y; inCin>>x>>y; -Mp[x][y] =1; to } + Floyd (); - intAns =0; the for(inti =1; I <= N; i++){ * intCNT =0; $ for(intj =1; J <= N; J + +){Panax Notoginseng if(i = =j) - Continue; the if(Mp[i][j] = =1|| Mp[j][i] = =1){ +cnt++; A } the } + if(cnt = = N1) -ans++; $ } $cout<<ans<<Endl; - return 0; -}
"POJ" 3660 Cow Contest