# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320194 | Karen124 | PIN (CEOI10_pin) | C++14 | 1046 ms | 107492 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;
#define ll long long
const ll N = 5e5 + 5;
const ll INF = 1e18 + 10;
int n, d, ans;
string a[N], b;
unordered_map <string, int> cn;
char add[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'g', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'x'};
int f(string s1, string s2){
int ret = 0;
for (int i = 0; i < 4; i++){
ret += (s1[i] != s2[i]);
}
return ret;
}
int main (){
cin >> n >> d;
if (n <= 2000){
for (int i = 0; i < n; i++){
cin >> a[i];
for (int j = 0; j < i; j++){
ans += (f(a[i], a[j]) == d);
}
}
cout << ans << '\n';
return 0;
}
if (d == 1)
for (int i = 0; i < n; i++){
cin >> a[i];
for (int j = 0; j < 36; j++){
if (add[j] == a[i][0]) continue;
b = a[i];
b[0] = add[j];
ans += cn[b];
}
for (int j = 0; j < 36; j++){
if (add[j] == a[i][1]) continue;
b = a[i];
b[1] = add[j];
}
for (int j = 0; j < 36; j++){
if (add[j] == a[i][2]) continue;
b = a[i];
b[2] = add[j];
ans += cn[b];
}
for (int j = 0; j < 36; j++){
if (add[j] == a[i][3]) continue;
b = a[i];
b[3] = add[j];
ans += cn[b];
}
cn[a[i]] ++;
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |