Submission #1090342

#TimeUsernameProblemLanguageResultExecution timeMemory
1090342andrei_iorgulescuGenetics (BOI18_genetics)C++14
46 / 100
2043 ms29136 KiB
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(8962);

int n, m, k;
char a[4105][4105];

bool mna(int x, int y)
{
    int df = 0;
    for (int i = 1; i <= m; i++)
        if (a[x][i] != a[y][i])
            df++;
    if (df == k)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++)
    {
        vector<int> alti;
        for (int j = 1; j <= n; j++)
            if (j != i)
                alti.push_back(j);
        shuffle(alti.begin(), alti.end(), default_random_engine(rng()));
        bool ok = true;
        for (auto it : alti)
        {
            if (!mna(i, it))
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            cout << i;
            return 0;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...