-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1303.cpp
More file actions
76 lines (65 loc) · 1.67 KB
/
1303.cpp
File metadata and controls
76 lines (65 loc) · 1.67 KB
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
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long llu;
typedef struct time{
llu id;
llu ponto;
llu marcado;
llu recebido;
time(){
id = 0;
ponto = 0;
marcado = 0;
recebido = 0;
}
} Time;
long double avarage(Time a){
long double x = a.recebido == 0 ? a.marcado : (long double) a.marcado / a.recebido;
return x;
}
bool ordena(Time a, Time b){
if(a.ponto == b.ponto){
if(avarage(a) == avarage(b)){
if(a.marcado == b.marcado){
return a.id < b.id;
}
return a.marcado > b.marcado;
}
return avarage(a) > avarage(b);
}
return a.ponto > b.ponto;
}
int main(){
llu n, x, y, z, w, i=1;
bool flag = false;
while(true){
cin >> n;
if(n == 0) break;
if (flag) cout << endl;
flag = true;
cout << "Instancia " << i++ << endl;
vector<Time> times(n);
for(llu j=0; j<(n * (n-1) / 2); ++j){
cin >> x >> y >> z >> w;
times[x-1].id = x;
times[x-1].marcado += y;
times[x-1].recebido += w;
times[z-1].id = z;
times[z-1].marcado += w;
times[z-1].recebido += y;
if(y > w){
times[x-1].ponto += 2;
times[z-1].ponto += 1;
}
else{
times[x-1].ponto += 1;
times[z-1].ponto += 2;
}
}
sort(times.begin(), times.end(), ordena);
for(llu j=0; j<n; ++j){
if(j == n-1) cout << times[j].id << endl;
else cout << times[j].id << " ";
}
}
}