# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135501 |
2019-07-24T06:59:38 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]][tmp[1]][tmp[2]][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]][tmp[1]][tmp[2]][tmp[3]]++;
tmp[k] = p[i][k];
}
thr += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
}
tmp[j] = p[i][j];
}
}
for(int i = 0; i < 36; i++) for(int j = 0; j < 36; j++) for(int k = 0; k < 36; k++) for(int l = 0; l < 36; l++)
cnt[i][j][k][l] = 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]][tmp[1]][tmp[2]][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]][tmp[1]][tmp[2]][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;
}
Compilation message
pin.cpp: In function 'int main()':
pin.cpp:29:20: warning: array subscript has type 'char' [-Wchar-subscripts]
two += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:29:28: warning: array subscript has type 'char' [-Wchar-subscripts]
two += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:29:36: warning: array subscript has type 'char' [-Wchar-subscripts]
two += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:29:44: warning: array subscript has type 'char' [-Wchar-subscripts]
two += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:34:24: warning: array subscript has type 'char' [-Wchar-subscripts]
fou += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:34:32: warning: array subscript has type 'char' [-Wchar-subscripts]
fou += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:34:40: warning: array subscript has type 'char' [-Wchar-subscripts]
fou += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:34:48: warning: array subscript has type 'char' [-Wchar-subscripts]
fou += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:37:22: warning: array subscript has type 'char' [-Wchar-subscripts]
thr += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:37:30: warning: array subscript has type 'char' [-Wchar-subscripts]
thr += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:37:38: warning: array subscript has type 'char' [-Wchar-subscripts]
thr += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:37:46: warning: array subscript has type 'char' [-Wchar-subscripts]
thr += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:47:21: warning: array subscript has type 'char' [-Wchar-subscripts]
zero += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:47:29: warning: array subscript has type 'char' [-Wchar-subscripts]
zero += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:47:37: warning: array subscript has type 'char' [-Wchar-subscripts]
zero += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:47:45: warning: array subscript has type 'char' [-Wchar-subscripts]
zero += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]]++;
^
pin.cpp:50:22: warning: array subscript has type 'char' [-Wchar-subscripts]
one += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:50:30: warning: array subscript has type 'char' [-Wchar-subscripts]
one += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:50:38: warning: array subscript has type 'char' [-Wchar-subscripts]
one += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
pin.cpp:50:46: warning: array subscript has type 'char' [-Wchar-subscripts]
one += cnt[tmp[0]][tmp[1]][tmp[2]][tmp[3]];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
6904 KB |
Output is correct |
2 |
Correct |
96 ms |
6904 KB |
Output is correct |
3 |
Correct |
76 ms |
6904 KB |
Output is correct |
4 |
Execution timed out |
1057 ms |
7160 KB |
Time limit exceeded |
5 |
Execution timed out |
1053 ms |
7160 KB |
Time limit exceeded |
6 |
Execution timed out |
1057 ms |
7160 KB |
Time limit exceeded |
7 |
Execution timed out |
1071 ms |
7160 KB |
Time limit exceeded |
8 |
Execution timed out |
1069 ms |
7160 KB |
Time limit exceeded |
9 |
Execution timed out |
1075 ms |
7304 KB |
Time limit exceeded |
10 |
Execution timed out |
1061 ms |
7416 KB |
Time limit exceeded |
11 |
Execution timed out |
1065 ms |
7176 KB |
Time limit exceeded |
12 |
Execution timed out |
1081 ms |
7416 KB |
Time limit exceeded |
13 |
Execution timed out |
1076 ms |
7160 KB |
Time limit exceeded |
14 |
Execution timed out |
1076 ms |
7164 KB |
Time limit exceeded |
15 |
Execution timed out |
1079 ms |
7416 KB |
Time limit exceeded |
16 |
Execution timed out |
1078 ms |
7288 KB |
Time limit exceeded |
17 |
Execution timed out |
1084 ms |
7416 KB |
Time limit exceeded |
18 |
Execution timed out |
1080 ms |
7288 KB |
Time limit exceeded |
19 |
Execution timed out |
1076 ms |
7416 KB |
Time limit exceeded |
20 |
Execution timed out |
1071 ms |
7416 KB |
Time limit exceeded |