-
Notifications
You must be signed in to change notification settings - Fork 1
/
torneiosub5.cpp
64 lines (47 loc) · 1.04 KB
/
torneiosub5.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
#include<bits/stdc++.h>
using namespace std;
int vencedorPartida(int a, int b);
int numeroVitorias(int competidor);
void responde(int tamanho, int array[]);
int saida[1001];
int query(int a, int b){
return vencedorPartida(a, b);
}
void ask(vector <int> &v, int novo){
for(auto x : v){
if(query(x, novo) == x){
saida[novo]++;
}
else{
saida[x]++;
}
}
if(saida[novo] <= 4) v.push_back(novo);
vector <int> at;
for(auto x : v){
if(saida[x] <= 4) at.push_back(x);
}
v = at;
return;
}
int resposta[1001];
void processaTorneio(int S, int n) {
vector <int> resp;
resp.push_back(1);
for(int i = 2;i <= n;i++){
ask(resp, i);
}
int con = 0;
for(auto x : resp){
int deg = 0;
for(int i = 1;i <= n;i++){
if(i == x) continue;
if(query(i, x) == i) deg++;
}
if(deg <= 4){
resposta[con] = x;
con++;
}
}
responde(con, &resposta[0]);
}