| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1339473 | po_rag526 | Parametriziran (COCI19_parametriziran) | C++20 | 980 ms | 4000 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)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
