# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
356711 |
2021-01-23T14:29:02 Z |
BlancaHM |
Scales (IOI15_scales) |
C++14 |
|
1000 ms |
512 KB |
#include "scales.h"
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
void init (int T) {
//
}
void permutaciones(vector<int> & permutacion, vector<bool> & seleccionado, int N, vector<vector<int>> & perm) {
if ((int) permutacion.size() == N) {
// ya están todos los números en la permutación
perm.push_back(permutacion);
return;
}
for (int i = 1; i <= N; i++) {
if (!seleccionado[i-1]) {
seleccionado[i-1] = true;
permutacion.push_back(i);
permutaciones(permutacion, seleccionado, N, perm);
permutacion.pop_back();
seleccionado[i-1] = false;
}
}
}
bool valida(vector<int> & secuencia, vector<int> & permutacion) {
int i = 0, j = 0;
while (i < (int) secuencia.size() && j < 6) {
if (permutacion[j] == secuencia[i])
i++;
j++;
}
return i == (int) secuencia.size();
}
void reducir(vector<int> secuencia, vector<vector<int>> & perm) {
vector<vector<int>> solucion = {};
for (int k = 0; k < (int) perm.size(); k++) {
if (valida(secuencia, perm[k]))
solucion.push_back(perm[k]);
}
perm = solucion;
}
void orderCoins() {
vector<vector<int>> perm; // guardamos aquí las permutaciones de los números 1 a 6
vector<int> p = {};
vector<bool> sel = vector<bool>(6, false);
permutaciones(p, sel, 6, perm);
int respuesta, A, B, C;
while((int) perm.size() > 1) {
A = perm[0][0];
B = perm[0][1];
C = perm[0][2];
respuesta = getHeaviest(A, B, C);
if (respuesta == A) {
reducir({B, A}, perm);
reducir({C, A}, perm);
} else if (respuesta == B) {
reducir({A, B}, perm);
reducir({C, B}, perm);
} else {
reducir({A, C}, perm);
reducir({B, C}, perm);
}
}
p = perm[0];
int solucion[6] = {p[0], p[1], p[2], p[3], p[4], p[5]};
answer(solucion);
return;
}
Compilation message
scales.cpp: In function 'void init(int)':
scales.cpp:7:16: warning: unused parameter 'T' [-Wunused-parameter]
7 | void init (int T) {
| ~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
372 KB |
Time limit exceeded |
2 |
Execution timed out |
1074 ms |
364 KB |
Time limit exceeded |
3 |
Execution timed out |
1043 ms |
364 KB |
Time limit exceeded |
4 |
Execution timed out |
1083 ms |
372 KB |
Time limit exceeded |
5 |
Execution timed out |
1095 ms |
364 KB |
Time limit exceeded |
6 |
Execution timed out |
1096 ms |
364 KB |
Time limit exceeded |
7 |
Execution timed out |
1082 ms |
364 KB |
Time limit exceeded |
8 |
Execution timed out |
1083 ms |
364 KB |
Time limit exceeded |
9 |
Execution timed out |
1072 ms |
364 KB |
Time limit exceeded |
10 |
Execution timed out |
1070 ms |
364 KB |
Time limit exceeded |
11 |
Execution timed out |
1057 ms |
364 KB |
Time limit exceeded |
12 |
Execution timed out |
1069 ms |
364 KB |
Time limit exceeded |
13 |
Execution timed out |
1098 ms |
364 KB |
Time limit exceeded |
14 |
Execution timed out |
1092 ms |
364 KB |
Time limit exceeded |
15 |
Execution timed out |
1087 ms |
364 KB |
Time limit exceeded |
16 |
Execution timed out |
1091 ms |
364 KB |
Time limit exceeded |
17 |
Execution timed out |
1094 ms |
384 KB |
Time limit exceeded |
18 |
Execution timed out |
1074 ms |
364 KB |
Time limit exceeded |
19 |
Execution timed out |
1055 ms |
512 KB |
Time limit exceeded |
20 |
Execution timed out |
1079 ms |
364 KB |
Time limit exceeded |
21 |
Execution timed out |
1048 ms |
364 KB |
Time limit exceeded |
22 |
Execution timed out |
1092 ms |
364 KB |
Time limit exceeded |
23 |
Execution timed out |
1089 ms |
364 KB |
Time limit exceeded |
24 |
Execution timed out |
1077 ms |
364 KB |
Time limit exceeded |
25 |
Execution timed out |
1057 ms |
364 KB |
Time limit exceeded |
26 |
Execution timed out |
1092 ms |
364 KB |
Time limit exceeded |
27 |
Execution timed out |
1078 ms |
364 KB |
Time limit exceeded |
28 |
Execution timed out |
1057 ms |
364 KB |
Time limit exceeded |
29 |
Execution timed out |
1085 ms |
364 KB |
Time limit exceeded |
30 |
Execution timed out |
1080 ms |
372 KB |
Time limit exceeded |
31 |
Execution timed out |
1092 ms |
364 KB |
Time limit exceeded |
32 |
Execution timed out |
1084 ms |
364 KB |
Time limit exceeded |
33 |
Execution timed out |
1062 ms |
364 KB |
Time limit exceeded |
34 |
Execution timed out |
1088 ms |
364 KB |
Time limit exceeded |
35 |
Execution timed out |
1065 ms |
364 KB |
Time limit exceeded |
36 |
Execution timed out |
1051 ms |
364 KB |
Time limit exceeded |
37 |
Execution timed out |
1056 ms |
364 KB |
Time limit exceeded |
38 |
Execution timed out |
1088 ms |
364 KB |
Time limit exceeded |
39 |
Execution timed out |
1049 ms |
364 KB |
Time limit exceeded |
40 |
Execution timed out |
1093 ms |
364 KB |
Time limit exceeded |