Submission #320195

# Submission time Handle Problem Language Result Execution time Memory
320195 2020-11-07T21:59:13 Z Karen124 PIN (CEOI10_pin) C++14
20 / 100
1000 ms 107412 KB
#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
1 Correct 39 ms 16012 KB Output is correct
2 Correct 36 ms 15980 KB Output is correct
3 Correct 26 ms 15980 KB Output is correct
4 Correct 884 ms 42704 KB Output is correct
5 Execution timed out 1056 ms 42704 KB Time limit exceeded
6 Incorrect 11 ms 15980 KB Output isn't correct
7 Incorrect 12 ms 15980 KB Output isn't correct
8 Execution timed out 1048 ms 42608 KB Time limit exceeded
9 Execution timed out 1068 ms 42704 KB Time limit exceeded
10 Incorrect 11 ms 15980 KB Output isn't correct
11 Incorrect 11 ms 15980 KB Output isn't correct
12 Incorrect 11 ms 15980 KB Output isn't correct
13 Incorrect 10 ms 15980 KB Output isn't correct
14 Incorrect 12 ms 15980 KB Output isn't correct
15 Incorrect 11 ms 16236 KB Output isn't correct
16 Execution timed out 1062 ms 107412 KB Time limit exceeded
17 Incorrect 11 ms 15980 KB Output isn't correct
18 Incorrect 11 ms 15980 KB Output isn't correct
19 Incorrect 11 ms 16256 KB Output isn't correct
20 Incorrect 11 ms 15980 KB Output isn't correct