Advertisement
xopsuei

league

Dec 18th, 2012
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. typedef vector<int> vi;
  7. typedef vector<vi> vii;
  8.  
  9. int main(){
  10.     int cases, teams, m, h, v, i , j, winner, max;
  11.    
  12.     vi scores;
  13.     vii matches;
  14.  
  15.     cin >> cases;
  16.     for(int k = 0; k < cases; ++k){
  17.         winner = max = 0;
  18.         cin >> teams >> m;
  19.  
  20.         scores = vi(teams, 0);
  21.         matches = vii(teams, vi(teams, -1));
  22.  
  23.         for(int p = 0; p < m; ++p){
  24.             cin >> h >> v >> i >> j;
  25.  
  26.             ++matches[h][v];
  27.             if(matches[h][v] == 0){
  28.                 if(i < j) scores[v] += 3;
  29.                 else if(i > j) scores[h] += 3;
  30.                 else{
  31.                     ++scores[h];
  32.                     ++scores[v];
  33.                 }
  34.             }
  35.         }
  36.  
  37.         for(int p = 0; p < teams; ++p){
  38.             if(scores[p] > max){
  39.                 max = scores[p];
  40.                 winner = p;
  41.             }
  42.         }
  43.  
  44.         cout << winner << endl;
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement