# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135421 |
2019-07-24T05:18:22 Z |
임유진(#3251) |
PIN (CEOI10_pin) |
C++14 |
|
1000 ms |
7288 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];
const int pw[4] = {36 * 36 * 36, 36 * 36, 36, 1};
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);
lint zero = 0, one = 0, two = 0, thr = 0, fou = 0;
for(int i = 0; i < N; i++) {
//printf("two = %lld\n", two);
char tmp[4];
int x = 0;
for(int j = 0; j < 4; j++) {
tmp[j] = p[i][j];
x += p[i][j] * pw[j];
}
two += cnt[x];
for(int j = 0; j < 4; j++) {
for(tmp[j] = 0, x -= p[i][j] * pw[j]; tmp[j] < 36; tmp[j]++, x += pw[j]) if(tmp[j] != p[i][j]) {
for(int k = j + 1; k < 4; k++) {
for(tmp[k] = 0, x -= p[i][k] * pw[k]; tmp[k] < 36; tmp[k]++, x += pw[k]) if(tmp[k] != p[i][k])
fou += cnt[x]++;
tmp[k] = p[i][k];
x += (p[i][k] - 36) * pw[k];
}
thr += cnt[x];
}
tmp[j] = p[i][j];
x += (p[i][j] - 36) * pw[j];
}
}
for(int i = 0; i < TOTAL; i++) cnt[i] = 0;
for(int i = 0; i < N; i++) {
char tmp[4];
int x = 0;
for(int j = 0; j < 4; j++) {
tmp[j] = p[i][j];
x += p[i][j] * pw[j];
}
zero += cnt[x]++;
for(int j = 0; j < 4; j++) {
for(tmp[j] = 0, x -= p[i][j] * pw[j]; tmp[j] < 36; tmp[j]++, x += pw[j]) if(tmp[j] != p[i][j])
one += cnt[x];
tmp[j] = p[i][j];
x += (p[i][j] - 36) * pw[j];
}
}
//printf("zero = %lld, one = %lld, two = %lld, thr = %lld, fou = %lld\n", zero, one, two, thr, fou);
if(D == 1) ans = one;
else if(D == 2) ans = two;
else if(D == 3) ans = (thr - 105 * one - 68 * two) / 3;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
6904 KB |
Output is correct |
2 |
Correct |
39 ms |
6904 KB |
Output is correct |
3 |
Incorrect |
33 ms |
6904 KB |
Output isn't correct |
4 |
Correct |
409 ms |
7032 KB |
Output is correct |
5 |
Correct |
517 ms |
7084 KB |
Output is correct |
6 |
Correct |
533 ms |
7032 KB |
Output is correct |
7 |
Correct |
424 ms |
7060 KB |
Output is correct |
8 |
Correct |
572 ms |
7084 KB |
Output is correct |
9 |
Correct |
906 ms |
7172 KB |
Output is correct |
10 |
Execution timed out |
1010 ms |
7196 KB |
Time limit exceeded |
11 |
Correct |
566 ms |
7100 KB |
Output is correct |
12 |
Execution timed out |
1004 ms |
7188 KB |
Time limit exceeded |
13 |
Correct |
637 ms |
7100 KB |
Output is correct |
14 |
Incorrect |
563 ms |
7160 KB |
Output isn't correct |
15 |
Incorrect |
971 ms |
7288 KB |
Output isn't correct |
16 |
Correct |
704 ms |
7120 KB |
Output is correct |
17 |
Execution timed out |
1054 ms |
7288 KB |
Time limit exceeded |
18 |
Incorrect |
806 ms |
7144 KB |
Output isn't correct |
19 |
Incorrect |
954 ms |
7260 KB |
Output isn't correct |
20 |
Execution timed out |
1080 ms |
7160 KB |
Time limit exceeded |