답안 #320199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320199 2020-11-07T22:47:57 Z Karen124 PIN (CEOI10_pin) C++14
60 / 100
88 ms 27364 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N = 5e4 + 5;
const ll M = 36;
const ll K = 16; 
ll all;
int n, d, z[5];
ll ans[5], ansp[5];
int cn[K][M][M][M][M];
unordered_map <char, short int> f;
string a[N];
int main (){
    f['0'] = 0; f['1'] = 1; f['2'] = 2; f['3'] = 3; f['4'] = 4; f['5'] = 5; f['6'] = 6; f['7'] = 7;
    f['8'] = 8; f['9'] = 9; f['a'] = 10; f['b'] = 11; f['c'] = 12; f['d'] = 13; f['e'] = 14; f['f'] = 15;
    f['g'] = 16; f['h'] = 17; f['i'] = 18; f['j'] = 19; f['k'] = 20; f['l'] = 21; f['m'] = 22; f['n'] = 23;
    f['o'] = 24; f['p'] = 25; f['q'] = 26; f['r'] = 27; f['s'] = 28; f['t'] = 29; f['u'] = 30; f['v'] = 31;
    f['w'] = 32; f['x'] = 33; f['y'] = 34; f['z'] = 35; 
    cin >> n >> d;
    all = 1ll * n * (n - 1) / 2ll;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        ansp[0] = ansp[1] = ansp[2] = ansp[3] = ansp[4] = 0;
        for (int msk = 0; msk < 16; msk++){
            z[0] = z[1] = z[2] = z[3] = 0;
            for (int j = 0; j < 4; j++){
                if ((msk >> j) & 1){
                    z[j] = f[a[i][j]];
                }
            }
            ansp[__builtin_popcount(msk)] += cn[msk][z[0]][z[1]][z[2]][z[3]]; 
            cn[msk][z[0]][z[1]][z[2]][z[3]] ++;
        }
        ans[4] += ansp[4];
        ans[3] += ansp[3] - ansp[4];
        ans[2] += ansp[2] - ansp[3] + ansp[4];
        ans[1] += ansp[1] - ansp[2] + ansp[3] - ansp[4];
        ans[0] += ansp[0] - ansp[1] + ansp[2] - ansp[3] + ansp[4];
    }
    cout << ans[4 - d] << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 7276 KB Output is correct
2 Incorrect 7 ms 7276 KB Output isn't correct
3 Correct 7 ms 7148 KB Output is correct
4 Correct 24 ms 7276 KB Output is correct
5 Correct 26 ms 7276 KB Output is correct
6 Incorrect 28 ms 7276 KB Output isn't correct
7 Incorrect 22 ms 7276 KB Output isn't correct
8 Correct 28 ms 7276 KB Output is correct
9 Correct 42 ms 7276 KB Output is correct
10 Incorrect 46 ms 7276 KB Output isn't correct
11 Incorrect 27 ms 7276 KB Output isn't correct
12 Incorrect 44 ms 7276 KB Output isn't correct
13 Incorrect 30 ms 7276 KB Output isn't correct
14 Correct 29 ms 7276 KB Output is correct
15 Correct 45 ms 7276 KB Output is correct
16 Correct 61 ms 27244 KB Output is correct
17 Incorrect 88 ms 27244 KB Output isn't correct
18 Correct 63 ms 27244 KB Output is correct
19 Correct 68 ms 27268 KB Output is correct
20 Correct 75 ms 27364 KB Output is correct