Submission #320194

# Submission time Handle Problem Language Result Execution time Memory
320194 2020-11-07T21:58:09 Z Karen124 PIN (CEOI10_pin) C++14
15 / 100
1000 ms 107492 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];
        }
        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 42 ms 15980 KB Output is correct
2 Correct 36 ms 16128 KB Output is correct
3 Correct 26 ms 15980 KB Output is correct
4 Incorrect 660 ms 38184 KB Output isn't correct
5 Incorrect 789 ms 38184 KB Output isn't correct
6 Incorrect 11 ms 15980 KB Output isn't correct
7 Incorrect 11 ms 15980 KB Output isn't correct
8 Incorrect 856 ms 38480 KB Output isn't correct
9 Execution timed out 1046 ms 38224 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 12 ms 15980 KB Output isn't correct
14 Incorrect 11 ms 15980 KB Output isn't correct
15 Incorrect 11 ms 15980 KB Output isn't correct
16 Execution timed out 1033 ms 107492 KB Time limit exceeded
17 Incorrect 11 ms 16128 KB Output isn't correct
18 Incorrect 11 ms 15980 KB Output isn't correct
19 Incorrect 11 ms 15980 KB Output isn't correct
20 Incorrect 11 ms 15980 KB Output isn't correct