44142023-03-27 18:41:46balaaaazsŐsi szövegcpp14Wrong answer 15/100248ms522996 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++) {
                d += (S[i][k] ^ S[j][k]) & 1;
            }
            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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted3ms2060 KiB
subtask24/4
3Accepted3ms2272 KiB
4Accepted3ms2428 KiB
5Accepted7ms3184 KiB
subtask311/11
6Accepted3ms2984 KiB
7Accepted3ms3136 KiB
8Accepted8ms3916 KiB
9Accepted8ms4064 KiB
10Accepted8ms4276 KiB
subtask40/21
11Accepted3ms3604 KiB
12Accepted3ms3976 KiB
13Wrong answer3ms3932 KiB
14Wrong answer3ms3932 KiB
15Accepted3ms3928 KiB
16Accepted3ms3980 KiB
subtask50/25
17Accepted28ms5740 KiB
18Accepted68ms6708 KiB
19Runtime error196ms522996 KiB
20Runtime error202ms522756 KiB
21Runtime error248ms522728 KiB
22Runtime error248ms522700 KiB
23Runtime error204ms522460 KiB
subtask60/39
24Accepted28ms6452 KiB
25Accepted68ms7568 KiB
26Runtime error196ms521972 KiB
27Runtime error201ms521752 KiB
28Runtime error206ms521532 KiB
29Runtime error202ms521520 KiB
30Runtime error246ms521488 KiB
31Runtime error203ms521492 KiB