# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
320195 | Karen124 | PIN (CEOI10_pin) | C++14 | 1068 ms | 107412 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
ans += cn[b];
}
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... |