# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
778948 | 2023-07-11T04:32:14 Z | 박상훈(#10000) | PIN (CEOI10_pin) | C++17 | 243 ms | 20460 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; map<vector<int>, ll> mp; ll ans[5]; char a[100100][6]; int main(){ int n, d; scanf("%d %d", &n, &d); vector<int> buf(4); for (int i=1;i<=n;i++){ scanf("%s", a[i]); ans[0] += i-1; for (int z=1;z<16;z++){ for (int j=0;j<4;j++){ if (z&(1<<j)) buf[j] = a[i][j]; else buf[j] = -1; } int c = __builtin_popcount(z); ll val = mp[buf]++; if (c==1){ ans[0] -= val; ans[1] += val; } else if (c==2){ ans[0] += val; ans[1] -= val*2; ans[2] += val; } else if (c==3){ ans[0] -= val; ans[1] += val*3; ans[2] -= val*3; ans[3] += val; } else if (c==4){ ans[0] += val; ans[1] -= val*4; ans[2] += val*6; ans[3] -= val*4; ans[4] += val; } } } printf("%lld\n", ans[4-d]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1236 KB | Output is correct |
2 | Correct | 5 ms | 1108 KB | Output is correct |
3 | Correct | 5 ms | 980 KB | Output is correct |
4 | Correct | 55 ms | 4488 KB | Output is correct |
5 | Correct | 67 ms | 5112 KB | Output is correct |
6 | Correct | 74 ms | 5120 KB | Output is correct |
7 | Correct | 68 ms | 4444 KB | Output is correct |
8 | Correct | 86 ms | 5328 KB | Output is correct |
9 | Correct | 122 ms | 7304 KB | Output is correct |
10 | Correct | 135 ms | 7852 KB | Output is correct |
11 | Correct | 83 ms | 5256 KB | Output is correct |
12 | Correct | 135 ms | 7632 KB | Output is correct |
13 | Correct | 91 ms | 5724 KB | Output is correct |
14 | Correct | 73 ms | 5316 KB | Output is correct |
15 | Correct | 161 ms | 7672 KB | Output is correct |
16 | Correct | 145 ms | 15552 KB | Output is correct |
17 | Correct | 243 ms | 20460 KB | Output is correct |
18 | Correct | 166 ms | 16984 KB | Output is correct |
19 | Correct | 195 ms | 18848 KB | Output is correct |
20 | Correct | 238 ms | 20384 KB | Output is correct |