답안 #496476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496476 2021-12-21T10:09:15 Z AkiYuu PIN (CEOI10_pin) C++17
70 / 100
170 ms 5832 KB
#include <bits/stdc++.h>
#define ll long long

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] + giong[2] - 3*giong[3];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1996 KB Output is correct
2 Correct 6 ms 1968 KB Output is correct
3 Incorrect 4 ms 1868 KB Output isn't correct
4 Correct 52 ms 3456 KB Output is correct
5 Correct 60 ms 3716 KB Output is correct
6 Correct 77 ms 3712 KB Output is correct
7 Correct 54 ms 3328 KB Output is correct
8 Correct 65 ms 3972 KB Output is correct
9 Correct 105 ms 5220 KB Output is correct
10 Correct 133 ms 5832 KB Output is correct
11 Correct 67 ms 3884 KB Output is correct
12 Correct 116 ms 5636 KB Output is correct
13 Correct 70 ms 4096 KB Output is correct
14 Incorrect 65 ms 3976 KB Output isn't correct
15 Incorrect 129 ms 5584 KB Output isn't correct
16 Correct 112 ms 4420 KB Output is correct
17 Correct 168 ms 5692 KB Output is correct
18 Incorrect 121 ms 4772 KB Output isn't correct
19 Incorrect 157 ms 5272 KB Output isn't correct
20 Incorrect 170 ms 5712 KB Output isn't correct