# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136829 | choikiwon | PIN (CEOI10_pin) | C++17 | 378 ms | 16504 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>
using namespace std;
const int maxn = 50010;
int N, D;
string pin[maxn];
int bcnt[16];
map<string, int> cnt[16];
int main() {
std::ios::sync_with_stdio(false);
for(int i = 0; i < 16; i++) {
for(int j = 0; j < 4; j++) if(i & (1 << j)) bcnt[i]++;
}
cin >> N >> D;
D = 4 - D;
for(int i = 0; i < N; i++) {
cin >> pin[i];
}
for(int i = 0; i < N; i++) {
for(int j = 0; j < 16; j++) {
string tmp;
for(int k = 0; k < 4; k++) {
if(j & (1 << k)) tmp.push_back(pin[i][k]);
else tmp.push_back(' ');
}
cnt[j][tmp]++;
}
}
int ans = 0;
for(int i = 0; i < 16; i++) {
if(bcnt[i] < D) continue;
for(auto it = cnt[i].begin(); it != cnt[i].end(); it++) {
if((bcnt[i] - D) % 2) ans -= 1LL * it->second * (it->second - 1) / 2;
else ans += 1LL * it->second * (it->second - 1) / 2;
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |