4413 | 2023-03-27 18:40:48 | balaaaazs | Ősi szöveg | cpp14 | Runtime error 36/100 | 250ms | 523632 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<string> S(N);
for (int i = 0; i < N; i++) {
cin >> S[i];
}
vector<vector<int>> dist(N, vector<int>(N, 0));
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
int d = 0;
for (int k = 0; k < K; k++) {
if (S[i][k] != S[j][k]) {
d++;
}
}
dist[i][j] = d;
dist[j][i] = d;
}
}
vector<double> avgdist(N, 0.0);
double divisor = N - 1;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (i != j) {
avgdist[i] += dist[i][j];
}
}
avgdist[i] /= divisor;
}
int min_index = min_element(avgdist.begin(), avgdist.end()) - avgdist.begin();
cout << min_index << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2068 KiB | ||||
subtask2 | 4/4 | ||||||
3 | Accepted | 3ms | 2284 KiB | ||||
4 | Accepted | 3ms | 2496 KiB | ||||
5 | Accepted | 7ms | 2988 KiB | ||||
subtask3 | 11/11 | ||||||
6 | Accepted | 3ms | 2724 KiB | ||||
7 | Accepted | 3ms | 2976 KiB | ||||
8 | Accepted | 8ms | 3696 KiB | ||||
9 | Accepted | 8ms | 3692 KiB | ||||
10 | Accepted | 8ms | 3952 KiB | ||||
subtask4 | 21/21 | ||||||
11 | Accepted | 3ms | 3232 KiB | ||||
12 | Accepted | 3ms | 3264 KiB | ||||
13 | Accepted | 3ms | 3264 KiB | ||||
14 | Accepted | 3ms | 3256 KiB | ||||
15 | Accepted | 3ms | 3332 KiB | ||||
16 | Accepted | 3ms | 3272 KiB | ||||
subtask5 | 0/25 | ||||||
17 | Accepted | 28ms | 5020 KiB | ||||
18 | Accepted | 72ms | 5988 KiB | ||||
19 | Runtime error | 240ms | 523632 KiB | ||||
20 | Runtime error | 246ms | 523596 KiB | ||||
21 | Runtime error | 250ms | 523564 KiB | ||||
22 | Runtime error | 250ms | 523332 KiB | ||||
23 | Runtime error | 247ms | 523320 KiB | ||||
subtask6 | 0/39 | ||||||
24 | Accepted | 28ms | 5716 KiB | ||||
25 | Accepted | 72ms | 6676 KiB | ||||
26 | Runtime error | 239ms | 522656 KiB | ||||
27 | Runtime error | 246ms | 522660 KiB | ||||
28 | Runtime error | 250ms | 522536 KiB | ||||
29 | Runtime error | 246ms | 522560 KiB | ||||
30 | Runtime error | 247ms | 522536 KiB | ||||
31 | Runtime error | 247ms | 522532 KiB |