提出 #46269993
ソースコード 拡げる
Copy
#include <stdio.h>#include <inttypes.h>int mex(int a, int b, int c) {int mask = 0;int i;mask |= 1 << a;mask |= 1 << b;mask |= 1 << c;for (i = 0; (mask >> i) & 1; i++);return i;}int N;int A[212345];char S[212345];int countLeft[3][212345];int countRight[3][12345];int main(void) {
#include <stdio.h>
#include <inttypes.h>
int mex(int a, int b, int c) {
int mask = 0;
int i;
mask |= 1 << a;
mask |= 1 << b;
mask |= 1 << c;
for (i = 0; (mask >> i) & 1; i++);
return i;
}
int N;
int A[212345];
char S[212345];
int countLeft[3][212345];
int countRight[3][12345];
int main(void) {
int i, j, k;
uint64_t ans = 0;
if (scanf("%d", &N) != 1) return 1;
for (i = 1; i <= N; i++) {
if (scanf("%d", &A[i]) != 1) return 1;
}
if (scanf("%212343s", S + 1) != 1) return 1;
for (i = 1; i <= N; i++) {
for (j = 0; j <= 2; j++) countLeft[j][i] = countLeft[j][i - 1];
if (S[i] == 'M') countLeft[A[i]][i]++;
}
for (i = N; i >= 1; i--) {
for (j = 0; j <= 2; j++) countRight[j][i] = countRight[j][i + 1];
if (S[i] == 'X') countRight[A[i]][i]++;
}
for (i = 1; i <= N; i++) {
if (S[i] == 'E') {
for (j = 0; j <= 2; j++) {
for (k = 0; k <= 2; k++) {
ans += (uint64_t)countLeft[j][i] * countRight[k][i] * mex(j, A[i], k);
}
}
}
}
printf("%" PRIu64 "\n", ans);
return 0;
}
提出情報
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 475 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 03_zero_00.txt, 03_zero_01.txt, 03_zero_02.txt, 04_handmade_00.txt, 04_handmade_01.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1760 KB |
| 00_sample_01.txt | AC | 1 ms | 1660 KB |
| 00_sample_02.txt | AC | 1 ms | 1760 KB |
| 01_random_00.txt | WA | 14 ms | 5068 KB |
| 01_random_01.txt | WA | 14 ms | 5216 KB |
| 01_random_02.txt | WA | 16 ms | 5188 KB |
| 01_random_03.txt | WA | 14 ms | 5112 KB |
| 01_random_04.txt | WA | 15 ms | 5208 KB |
| 01_random_05.txt | WA | 14 ms | 5164 KB |
| 01_random_06.txt | WA | 15 ms | 5184 KB |
| 01_random_07.txt | WA | 15 ms | 5108 KB |
| 01_random_08.txt | WA | 15 ms | 5128 KB |
| 01_random_09.txt | WA | 15 ms | 5100 KB |
| 01_random_10.txt | WA | 15 ms | 5124 KB |
| 01_random_11.txt | WA | 15 ms | 5212 KB |
| 01_random_12.txt | WA | 15 ms | 5168 KB |
| 01_random_13.txt | WA | 15 ms | 5044 KB |
| 01_random_14.txt | WA | 15 ms | 5208 KB |
| 01_random_15.txt | WA | 15 ms | 5140 KB |
| 01_random_16.txt | WA | 15 ms | 5072 KB |
| 01_random_17.txt | WA | 15 ms | 5124 KB |
| 01_random_18.txt | WA | 15 ms | 5164 KB |
| 01_random_19.txt | WA | 15 ms | 5184 KB |
| 02_random2_00.txt | WA | 12 ms | 5216 KB |
| 02_random2_01.txt | WA | 16 ms | 5204 KB |
| 02_random2_02.txt | WA | 12 ms | 5112 KB |
| 03_zero_00.txt | AC | 13 ms | 5216 KB |
| 03_zero_01.txt | WA | 16 ms | 5216 KB |
| 03_zero_02.txt | WA | 15 ms | 5208 KB |
| 04_handmade_00.txt | AC | 1 ms | 1628 KB |
| 04_handmade_01.txt | WA | 13 ms | 5168 KB |