Submission #916601

# Submission time Handle Problem Language Result Execution time Memory
916601 2024-01-26T06:54:52 Z 406 Genetics (BOI18_genetics) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ar = array<int, 2>;

const int64_t INF = 1ll << 60;
const int N = 4200;
int n, m, k;
vector<pair<string, int>> a, tmp;

bool get(const string &s1, const string &s2) {
        int x = 0;
        FOR(i, 0, m) {
                x += s1[i] != s2[i];
                if (x > k) return false;
        }
        return x == k;
}

signed main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr); 
        cin >> n >> m >> k;
        a.resize(n);
        (i, 0, n) {
                string s;
                cin >> s;
                a[i] = {s, i};
        }
        mt19937 rng((int64_t) new char);
        tmp = a;
        //shuffle(a.begin(), a.end(), rng);

        /*
        while (a.size() >= 10) {
                int i = rng() % a.size(), j;
                do {
                        j = rng() % a.size();
                } while (j == i);
                if (!get(a[i].first, a[j].first)) {
                        if (i > j) swap(i, j);
                        a.erase(a.begin() + j);
                        a.erase(a.begin() + i);
                }
        }
        */

        FOR(i, 0, a.size()) {
                bool f = true;
                for (auto &[s, x]: tmp) if (x != a[i].second)
                        f &= get(a[i].first, s);
                if (f) {
                        cout << a[i].second + 1;
                        return 0;
                }
        }
        return 0;
}

Compilation message

genetics.cpp: In function 'int main()':
genetics.cpp:27:10: error: 'i' was not declared in this scope
   27 |         (i, 0, n) {
      |          ^
genetics.cpp:3:42: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::pair<std::__cxx11::basic_string<char>, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
      |                                          ^
genetics.cpp:50:9: note: in expansion of macro 'FOR'
   50 |         FOR(i, 0, a.size()) {
      |         ^~~