# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238950 | dolphingarlic | PIN (CEOI10_pin) | C++14 | 100 ms | 8552 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
unordered_map<ll, int> cnt[16];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d;
cin >> n >> d;
FOR(i, 0, n) {
string s;
cin >> s;
FOR(j, 0, 16) {
ll hsh = 0;
FOR(k, 0, 4) if (j & (1 << k))
hsh += (s[k] - '0' + 1) << (k * 8);
cnt[j][hsh]++;
}
}
int ans = 0;
FOR(i, 0, 16) {
if (4 - __builtin_popcount(i) > d) continue;
int contrib = 0;
for (pair<ll, int> j : cnt[i])
contrib += j.second * (j.second - 1) / 2;
if ((d - 4 + __builtin_popcount(i)) & 1) ans -= contrib;
else ans += contrib;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |