"POJ" 3660 Cow Contest

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.