이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 50010;
const int twoidx[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
const int thridx[4][3] = {{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}};
char S[MAXN][5];
int one[4][36], two[6][36][36], thr[4][36][36][36];
int gtwo(int j, int i) { return two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]; }
int gthr(int j, int i) { return thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]; }
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int N, D;
cin >> N >> D;
for(int i = 0; i < N; i++) cin >> S[i];
lint ans = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j < 4; j++) S[i][j] -= '0' <= S[i][j] && S[i][j] <= '9' ? '0' : ('a' - 10);
int cnt[4] = {0, 0, 0, 0};
for(int j = 0; j < 4; j++)
cnt[3] += gthr(j, i);
for(int j = 0; j < 6; j++) cnt[2] += gtwo(j, i);
cnt[2] -= cnt[3] * 3;
for(int j = 0; j < 4; j++) cnt[1] += one[j][S[i][j]];
cnt[1] -= cnt[2] * 2 + cnt[3] * 3;
cnt[0] = i - cnt[1] - cnt[2] - cnt[3];
ans += cnt[4 - D];
for(int j = 0; j < 4; j++) one[j][S[i][j]]++;
for(int j = 0; j < 6; j++) two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]++;
for(int j = 0; j < 4; j++) thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]++;
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
pin.cpp: In function 'int gtwo(int, int)':
pin.cpp:13:58: warning: array subscript has type 'char' [-Wchar-subscripts]
int gtwo(int j, int i) { return two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]; }
^
pin.cpp:13:78: warning: array subscript has type 'char' [-Wchar-subscripts]
int gtwo(int j, int i) { return two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]; }
^
pin.cpp: In function 'int gthr(int, int)':
pin.cpp:14:58: warning: array subscript has type 'char' [-Wchar-subscripts]
int gthr(int j, int i) { return thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]; }
^
pin.cpp:14:78: warning: array subscript has type 'char' [-Wchar-subscripts]
int gthr(int j, int i) { return thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]; }
^
pin.cpp:14:98: warning: array subscript has type 'char' [-Wchar-subscripts]
int gthr(int j, int i) { return thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]; }
^
pin.cpp: In function 'int main()':
pin.cpp:31:54: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 4; j++) cnt[1] += one[j][S[i][j]];
^
pin.cpp:36:44: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 4; j++) one[j][S[i][j]]++;
^
pin.cpp:37:55: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 6; j++) two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]++;
^
pin.cpp:37:75: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 6; j++) two[j][S[i][twoidx[j][0]]][S[i][twoidx[j][1]]]++;
^
pin.cpp:38:55: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 4; j++) thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]++;
^
pin.cpp:38:75: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 4; j++) thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]++;
^
pin.cpp:38:95: warning: array subscript has type 'char' [-Wchar-subscripts]
for(int j = 0; j < 4; j++) thr[j][S[i][thridx[j][0]]][S[i][thridx[j][1]]][S[i][thridx[j][2]]]++;
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |