44112023-03-27 18:30:03balaaaazsŐsi szövegcpp14Runtime error 36/100250ms522768 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted3ms2056 KiB
subtask24/4
3Accepted2ms2272 KiB
4Accepted3ms2528 KiB
5Accepted7ms2952 KiB
subtask311/11
6Accepted2ms2564 KiB
7Accepted3ms2820 KiB
8Accepted9ms3608 KiB
9Accepted9ms3644 KiB
10Accepted10ms3900 KiB
subtask421/21
11Accepted3ms3316 KiB
12Accepted6ms3572 KiB
13Accepted4ms3744 KiB
14Accepted3ms3700 KiB
15Accepted6ms3756 KiB
16Accepted4ms3756 KiB
subtask50/25
17Accepted35ms5768 KiB
18Accepted219ms6764 KiB
19Runtime error202ms522768 KiB
20Runtime error204ms522524 KiB
21Runtime error219ms522436 KiB
22Runtime error207ms522392 KiB
23Runtime error209ms522160 KiB
subtask60/39
24Accepted34ms6476 KiB
25Accepted222ms7600 KiB
26Runtime error196ms522176 KiB
27Runtime error202ms522172 KiB
28Runtime error247ms522176 KiB
29Runtime error250ms521956 KiB
30Runtime error248ms521944 KiB
31Runtime error246ms521708 KiB