# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
135393 |
2019-07-24T04:42:57 Z |
임유진(#3251) |
PIN (CEOI10_pin) |
C++14 |
|
115 ms |
7160 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 50005;
const int TOTAL = 36 * 36 * 36 * 36;
char p[MAXN][5];
int cnt[TOTAL];
int tonum(char s[]) { return 36 * 36 * 36 * int(s[0]) + 36 * 36 * int(s[1]) + 36 * int(s[2]) + int(s[3]); }
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int N, D;
lint ans = 0ll;
cin >> N >> D;
for(int i = 0; i < N; i++) cin >> p[i];
for(int i = 0; i < N; i++) for(int j = 0; j < 4; j++)
p[i][j] = '0' <= p[i][j] && p[i][j] <= '9' ? (p[i][j] - '0') : (p[i][j] - 'a' + 10);
if(D == 1) {
for(int i = 0; i < N; i++) {
char tmp[4];
for(int j = 0; j < 4; j++) tmp[j] = p[i][j];
for(int j = 0; j < 4; j++) {
for(int k = 0; k < 36; k++) if(k != p[i][j]) {
tmp[j] = k;
ans += cnt[tonum(tmp)];
//if(cnt[tonum(tmp)] != 0) printf("j = %d, tonum(%d %d %d %d) = %d\n", j, tmp[0], tmp[1], tmp[2], tmp[3], tonum(tmp));
}
tmp[j] = p[i][j];
}
cnt[tonum(p[i])]++;
//printf("tonum(p[i]) = %d\n", tonum(p[i]));
//printf("ans = %lld\n", ans);
}
}
else if(D == 2) {
lint two = 0ll, one = 0ll, zero = 0ll;
for(int i = 0; i < N; i++) {
//printf("i = %d\n", i);
char tmp[4];
for(int j = 0; j < 4; j++) tmp[j] = p[i][j];
for(int j = 0; j < 4; j++) {
for(int k = 0; k < 36; k++) if(k != p[i][j]) {
tmp[j] = k;
two += cnt[tonum(tmp)];
//if(cnt[tonum(tmp)] != 0) printf("j = %d, tonum(%d %d %d %d) = %d\n", j, tmp[0], tmp[1], tmp[2], tmp[3], tonum(tmp));
cnt[tonum(tmp)]++;
}
tmp[j] = p[i][j];
}
}
for(int i = 0; i < TOTAL; i++) cnt[i] = 0;
for(int i = 0; i < N; i++) {
char tmp[4];
for(int j = 0; j < 4; j++) tmp[j] = p[i][j];
for(int j = 0; j < 4; j++) {
for(int k = 0; k < 36; k++) if(k != p[i][j]) {
tmp[j] = k;
//if(i == 3 && k == 1) printf("cnt[%d %d %d %d] = %d\n", tmp[0], tmp[1], tmp[2], tmp[3]
one += cnt[tonum(tmp)];
}
tmp[j] = p[i][j];
}
zero += cnt[tonum(p[i])];
cnt[tonum(p[i])]++;
}
ans = (two - one * 34 - 4 * 35 * zero) / 2;
//printf("two = %lld, one = %lld, zero = %lld\n", two, one, zero);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1656 KB |
Output is correct |
2 |
Correct |
13 ms |
6904 KB |
Output is correct |
3 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
4 |
Correct |
17 ms |
1784 KB |
Output is correct |
5 |
Correct |
20 ms |
1784 KB |
Output is correct |
6 |
Correct |
51 ms |
7032 KB |
Output is correct |
7 |
Correct |
45 ms |
7032 KB |
Output is correct |
8 |
Correct |
23 ms |
1784 KB |
Output is correct |
9 |
Correct |
34 ms |
1912 KB |
Output is correct |
10 |
Correct |
96 ms |
7160 KB |
Output is correct |
11 |
Correct |
56 ms |
7032 KB |
Output is correct |
12 |
Incorrect |
6 ms |
632 KB |
Output isn't correct |
13 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
14 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
15 |
Incorrect |
6 ms |
576 KB |
Output isn't correct |
16 |
Correct |
40 ms |
7032 KB |
Output is correct |
17 |
Correct |
115 ms |
7160 KB |
Output is correct |
18 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
19 |
Incorrect |
6 ms |
604 KB |
Output isn't correct |
20 |
Incorrect |
6 ms |
632 KB |
Output isn't correct |