Submission #232473

# Submission time Handle Problem Language Result Execution time Memory
232473 2020-05-17T07:01:48 Z VEGAnn Parametriziran (COCI19_parametriziran) C++14
11 / 110
1311 ms 49752 KB
#include <bits/stdc++.h>
#define ft first
#define sd second
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 50100;
unordered_map<string, int> mem[(1 << 6)];
string s[N], t;
int n, m, kol[(1 << 6)];
ll ans = 0;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m;

    for (int i = 0; i < n; i++){
        cin >> s[i];

        for (int msk = 1; msk < (1 << m); msk++){
            t = "";
            bool bad = 0;

            for (int j = 0; j < m && !bad; j++)
                if (msk & (1 << j)) {
                    if (s[i][j] == '?')
                        bad = 1;
                    else t += s[i][j];
                }

            if (!bad) {
                mem[msk][t]++;
                kol[msk]++;
            }
        }
    }

    for (int i = 0; i < n; i++){
        int cur = n - 1;

        for (int msk = 1; msk < (1 << m); msk++){
            t = "";
            bool bad = 0;

            for (int j = 0; j < m && !bad; j++)
                if (msk & (1 << j)) {
                    if (s[i][j] == '?')
                        bad = 1;
                    else t += s[i][j];
                }

            if (!bad)
                cur += ((kol[msk] - mem[msk][t]) * (__builtin_parity(msk) ? -1 : 1));
        }

        ans += cur;
    }

    assert(ans % 2 == 0);

    cout << ans / 2;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 2812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 162 ms 8824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 262 ms 12128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 577 ms 24264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1041 ms 35904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1311 ms 49752 KB Output isn't correct
2 Halted 0 ms 0 KB -