답안 #496475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496475 2021-12-21T10:08:01 Z AkiYuu PIN (CEOI10_pin) C++17
70 / 100
181 ms 5932 KB
#include <bits/stdc++.h>
#define ll long long
//debug
using namespace std;

string s[50001];
ll giong[5];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,D;
    cin >> n >> D;
    for (int i = 1; i <= n; i++) cin >> s[i];
    for (int mask = 0; mask < (1 << 4); mask++) {
        map<string,int> mp;
        mp.clear();
        int cnt = __builtin_popcount(mask);
        for (int i = 1; i <= n; i++) {
            string tmp;
            for (int j = 0; j < 4; j++)
                if (mask & (1 << j)) tmp = tmp + s[i][j];
            mp[tmp]++;
        }
        for (auto i: mp)
            giong[cnt] += (i.second - 1)*(i.second)/2;
    }
    if (D == 1) cout << giong[3];
    else if (D == 2) cout << giong[2] - 3*giong[3];
    else if (D == 3) cout << giong[1]  - 2*giong[2] + 3*giong[3];
    else cout << giong[0] - giong[1] + 2*giong[2] - 3*giong[3];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1996 KB Output is correct
2 Correct 5 ms 1976 KB Output is correct
3 Incorrect 5 ms 1868 KB Output isn't correct
4 Correct 48 ms 3340 KB Output is correct
5 Correct 61 ms 3720 KB Output is correct
6 Correct 67 ms 3716 KB Output is correct
7 Correct 56 ms 3332 KB Output is correct
8 Correct 66 ms 3972 KB Output is correct
9 Correct 106 ms 5248 KB Output is correct
10 Correct 128 ms 5640 KB Output is correct
11 Correct 67 ms 3844 KB Output is correct
12 Correct 122 ms 5516 KB Output is correct
13 Correct 71 ms 4064 KB Output is correct
14 Incorrect 64 ms 3896 KB Output isn't correct
15 Incorrect 123 ms 5512 KB Output isn't correct
16 Correct 110 ms 4392 KB Output is correct
17 Correct 181 ms 5932 KB Output is correct
18 Incorrect 121 ms 4788 KB Output isn't correct
19 Incorrect 148 ms 5300 KB Output isn't correct
20 Incorrect 169 ms 5692 KB Output isn't correct