Submission #1339467

#TimeUsernameProblemLanguageResultExecution timeMemory
1339467vjudge1Parametriziran (COCI19_parametriziran)C++17
110 / 110
1008 ms3996 KiB
#include <bits/stdc++.h>
#warning That's not NP, that's my NP!
using namespace std;

typedef long long ll;

const int N = 5e4, M = 6;

vector<string> group[1 << M];

signed main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;

        int on_mask = 0;
        for (int j = 0; j < m; j++) {
            if (s[j] != '?') {
                on_mask += (1 << j);
            }
        }
        group[on_mask].push_back(s);
    }
    int ans = 0;
    for (int mask1 = 0; mask1 < (1 << m); mask1++) {
        for (int mask2 = 0; mask2 < (1 << m); mask2++) {
            map<string, int> f;
            for (auto str : group[mask1]) {
                string common;
                for (int j = 0; j < m; j++) {
                    if (mask1 & (1 << j) && mask2 & (1 << j)) {
                        common.push_back(str[j]);
                    }
                }
                f[common]++;
            }
            for (auto str : group[mask2]) {
                string common;
                for (int j = 0; j < m; j++) {
                    if (mask1 & (1 << j) && mask2 & (1 << j)) {
                        common.push_back(str[j]);
                    }
                }
                // f[common]++;
                ans += f[common];
            }
        }
    }
    cout << (ans - n) / 2 << "\n";
    return 0;
}

Compilation message (stderr)

Main.cpp:2:2: warning: #warning That's not NP, that's my NP! [-Wcpp]
    2 | #warning That's not NP, that's my NP!
      |  ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...