# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135504 |
2019-07-24T07:12:52 Z |
임유진(#3251) |
PIN (CEOI10_pin) |
C++14 |
|
1000 ms |
7416 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[36*36][36*36];
//const int pw[4] = {36 * 36 * 36, 36 * 36, 36, 1};
int main() {
ios_base::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];
for(int j = 0; j < 4; j++) tmp[j] = p[i][j];
two += cnt[tmp[0] * 36 + tmp[1]][tmp[2] * 36 + tmp[3]];
for(int j = 0; j < 4; j++) {
for(tmp[j] = 0; tmp[j] < 36; tmp[j]++) if(tmp[j] != p[i][j]) {
for(int k = j + 1; k < 4; k++) {
for(tmp[k] = 0; tmp[k] < 36; tmp[k]++) if(tmp[k] != p[i][k])
fou += cnt[tmp[0] * 36 + tmp[1]][tmp[2] * 36 + tmp[3]]++;
tmp[k] = p[i][k];
}
thr += cnt[tmp[0] * 36 + tmp[1]][tmp[2] * 36 + tmp[3]];
}
tmp[j] = p[i][j];
}
}
for(int i = 0; i < 36 * 36; i++) for(int j = 0; j < 36 * 36; j++)
cnt[i][j] = 0;
for(int i = 0; i < N; i++) {
char tmp[4];
for(int j = 0; j < 4; j++) tmp[j] = p[i][j];
zero += cnt[tmp[0] * 36 + tmp[1]][tmp[2] * 36 + tmp[3]]++;
for(int j = 0; j < 4; j++) {
for(tmp[j] = 0; tmp[j] < 36; tmp[j]++) if(tmp[j] != p[i][j])
one += cnt[tmp[0] * 36 + tmp[1]][tmp[2] * 36 + tmp[3]];
tmp[j] = p[i][j];
}
}
thr = (thr - 105 * one - 68 * two) / 3;
fou = (fou - 3570 * one - 1296 * two - 204 * thr) / 6;
//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;
else ans = fou;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
7032 KB |
Output is correct |
2 |
Correct |
95 ms |
6904 KB |
Output is correct |
3 |
Correct |
89 ms |
7032 KB |
Output is correct |
4 |
Execution timed out |
1056 ms |
7160 KB |
Time limit exceeded |
5 |
Execution timed out |
1049 ms |
7164 KB |
Time limit exceeded |
6 |
Execution timed out |
1070 ms |
7160 KB |
Time limit exceeded |
7 |
Execution timed out |
1077 ms |
7132 KB |
Time limit exceeded |
8 |
Execution timed out |
1076 ms |
7164 KB |
Time limit exceeded |
9 |
Execution timed out |
1032 ms |
7288 KB |
Time limit exceeded |
10 |
Execution timed out |
1043 ms |
7340 KB |
Time limit exceeded |
11 |
Execution timed out |
1061 ms |
7160 KB |
Time limit exceeded |
12 |
Execution timed out |
1057 ms |
7416 KB |
Time limit exceeded |
13 |
Execution timed out |
1070 ms |
7288 KB |
Time limit exceeded |
14 |
Execution timed out |
1064 ms |
7160 KB |
Time limit exceeded |
15 |
Execution timed out |
1069 ms |
7388 KB |
Time limit exceeded |
16 |
Execution timed out |
1088 ms |
7288 KB |
Time limit exceeded |
17 |
Execution timed out |
1071 ms |
7416 KB |
Time limit exceeded |
18 |
Execution timed out |
1069 ms |
7288 KB |
Time limit exceeded |
19 |
Execution timed out |
1043 ms |
7288 KB |
Time limit exceeded |
20 |
Execution timed out |
1024 ms |
7268 KB |
Time limit exceeded |