@syntax_hacker0/

efficientprimes

C++

No description

fork
loading
Files
  • main.cpp
  • inp.txt
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <bits/stdc++.h>
using std::ifstream;
using std::pair;
#define fri(i,n) for(int i = 1 ; i <=n;++i) //inc from front
#define jri(j,k,n) for(int j = k ; j >= n;j--) //dec frm last
// Need to add a check to make sure you are not swapping the same // variable with itself. Otherwise it will zero the value.
#define swapnumsxor a ^= b; b ^= a; a ^= b
#define inp(i) in >> i 
#define inp2(i,j) in >> i >> j 
#define inp3(i,j,k) in >> i >> j >> k
#define oup(i) cout << i << "\n"
#define oup3(i,j,k) cout << i << " "<< j << " "<<k<< "\n"
#define oups(i) cout << i << " "
#define toup(i) cout << "output - "<<  i << "\n"
#define mod 1e9 + 7
#define rmdup std::sort(str.begin(), str.end());str.erase(std::unique(str.begin(), str.end()), str.end());
typedef long long int lli;
// typedef pair<int,int> pii;
// typedef vector<int> vec;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first;
#define sd second;

#define MAXN 1000000
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::map;
using std::sort;
using std::ios_base;
unsigned gcd(unsigned a, unsigned b)
{
    if (b) return gcd(b, a % b);
    else return a;

}

int main()
{ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
		ifstream in("inp.txt");
		int n,matches,t1,t2;
		unsigned int g1,g2;
    inp(n);
		matches = (n*(n-1))/2;
		map<int,int> scoreboard;
		vector<int>score(n,0);
		vector<int>goals(n);
    while(matches--){
			in>>t1>>t2>>g1>>g2;
			if( g1 > g2){
				score[t1]+=4;
			}else if(g2>g1){
				score[t2]+=4;
			}else{
				score[t1]+=1;
				score[t2]+=1;
			}
			scoreboard[t1]+=g1;
			scoreboard[t2]+=g2;
			
			scoreboard.insert(std::make_pair(t1,g1));
			scoreboard.insert(std::make_pair(t2,g2));
		}
		map<int,int> ::iterator it;
		for(auto it =scoreboard.begin() ; it !=scoreboard.end() ;++it){
			cout << it->first << " " << it->second << "\n";
		}
	sort(score.begin(), score.end() , std::greater<int>());
  sort( goals.begin(), goals.end() , std::greater<int>());
	if(score[0] == score[1]){
		
	} else cout << scoreboard.find(score[0])->first;
    return 0;
}

// 4
// 1 2 2 1
// 1 3 1 1
// 4 2 2 3
// 4 1 1 0
// 3 4 3 0
// 3 2 0 0