Submission #97291

# Submission time Handle Problem Language Result Execution time Memory
97291 2019-02-14T20:23:02 Z IgorBaliuk Parametriziran (COCI19_parametriziran) C++14
0 / 110
394 ms 4148 KB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;
const int N = 50005;

unordered_map <string, int> used;
vector <string> str[64];
int n, m;
ll result = 0;

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

    cin >> n >> m;

    int M = 1 << m;

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

		int mask = 0;

		for (int j = 0; j < m; j++)
			mask |= (s[j] != '?') << j;

		str[mask].push_back(s);
    }

	auto process = [&](int a, int b) {
		used.clear();

		for (auto it : str[a]) {
			string cur = "";

			for (int i = 0; i < m; i++) {
				if (((a >> i) & 1) && ((b >> i) & 1))
					cur += it[i];
			}

			used[cur]++;
		}

		for (auto it : str[b]) {
			string cur = "";

			for (int i = 0; i < m; i++) {
				if (((a >> i) & 1) && ((b >> i) & 1))
					cur += it[i];
			}

			result += used[cur];
		}
	};

	for (int i = 0; i < M; i++) {
		for (int j = i; j < M; j++)
			process(i, j);
	}

    cout << result - n << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2680 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 2608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 4148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 2428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 4020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 327 ms 2960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 394 ms 3692 KB Output isn't correct
2 Halted 0 ms 0 KB -