4411 | 2023-03-27 18:30:03 | balaaaazs | Ősi szöveg | cpp14 | Runtime error 36/100 | 250ms | 522768 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
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++) {
for (int k = 0; k < K; k++) {
if (S[i][k] != S[j][k]) {
dist[i][j]++;
}
}
dist[j][i] = dist[i][j];
}
}
vector<double> avgdist(N, 0.0);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (i != j) {
avgdist[i] += dist[i][j];
}
}
avgdist[i] /= (N - 1);
}
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 | 2056 KiB | ||||
subtask2 | 4/4 | ||||||
3 | Accepted | 2ms | 2272 KiB | ||||
4 | Accepted | 3ms | 2528 KiB | ||||
5 | Accepted | 7ms | 2952 KiB | ||||
subtask3 | 11/11 | ||||||
6 | Accepted | 2ms | 2564 KiB | ||||
7 | Accepted | 3ms | 2820 KiB | ||||
8 | Accepted | 9ms | 3608 KiB | ||||
9 | Accepted | 9ms | 3644 KiB | ||||
10 | Accepted | 10ms | 3900 KiB | ||||
subtask4 | 21/21 | ||||||
11 | Accepted | 3ms | 3316 KiB | ||||
12 | Accepted | 6ms | 3572 KiB | ||||
13 | Accepted | 4ms | 3744 KiB | ||||
14 | Accepted | 3ms | 3700 KiB | ||||
15 | Accepted | 6ms | 3756 KiB | ||||
16 | Accepted | 4ms | 3756 KiB | ||||
subtask5 | 0/25 | ||||||
17 | Accepted | 35ms | 5768 KiB | ||||
18 | Accepted | 219ms | 6764 KiB | ||||
19 | Runtime error | 202ms | 522768 KiB | ||||
20 | Runtime error | 204ms | 522524 KiB | ||||
21 | Runtime error | 219ms | 522436 KiB | ||||
22 | Runtime error | 207ms | 522392 KiB | ||||
23 | Runtime error | 209ms | 522160 KiB | ||||
subtask6 | 0/39 | ||||||
24 | Accepted | 34ms | 6476 KiB | ||||
25 | Accepted | 222ms | 7600 KiB | ||||
26 | Runtime error | 196ms | 522176 KiB | ||||
27 | Runtime error | 202ms | 522172 KiB | ||||
28 | Runtime error | 247ms | 522176 KiB | ||||
29 | Runtime error | 250ms | 521956 KiB | ||||
30 | Runtime error | 248ms | 521944 KiB | ||||
31 | Runtime error | 246ms | 521708 KiB |