Submission #72575127
Source Code Expand
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
using namespace std;
int h, w;
cin >> h >> w;
vector<string> s(h);
for (auto &e : s) cin >> e;
using lint = unsigned long long;
vector ce(h + 1, vector(w + 1, 0ll));
vector cf(h + 1, vector(w + 1, 0ll));
vector cg(h + 1, vector(w + 1, 0ll));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ce[i + 1][j + 1] = s[i][j] == 'E';
cf[i + 1][j + 1] = s[i][j] == 'F';
cg[i + 1][j + 1] = s[i][j] == 'G';
}
}
for (int i = 0; i <= h; ++i) {
for (int j = 0; j < w; ++j) {
ce[i][j + 1] += ce[i][j];
cf[i][j + 1] += cf[i][j];
cg[i][j + 1] += cg[i][j];
}
}
for (int i = 0; i < h; ++i) {
for (int j = 0; j <= w; ++j) {
ce[i + 1][j] += ce[i][j];
cf[i + 1][j] += cf[i][j];
cg[i + 1][j] += cg[i][j];
}
}
auto get = [](auto &ta, int i1, int j1, int i2, int j2) {
return ta[i2][j2] - ta[i1][j2] - ta[i2][j1] + ta[i1][j1];
};
lint ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ans += get(ce, 0, 0, i, j)
* get(cf, i, j + 1, i + 1, w)
* get(cg, i + 1, j, h, j + 1);
}
}
cout << ans << "\n";
}
Submission Info
| Submission Time |
|
| Task |
G - EGFグリッド |
| User |
guild2026_186 |
| Language |
C++23 (GCC 15.2.0) |
| Score |
100 |
| Code Size |
1440 Byte |
| Status |
AC |
| Exec Time |
137 ms |
| Memory |
105116 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
100 / 100 |
| Status |
|
|
| Set Name |
Test Cases |
| 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 |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3496 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3664 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3484 KiB |
| 01_random_00.txt |
AC |
41 ms |
35088 KiB |
| 01_random_01.txt |
AC |
14 ms |
13820 KiB |
| 01_random_02.txt |
AC |
48 ms |
40708 KiB |
| 01_random_03.txt |
AC |
132 ms |
104980 KiB |
| 01_random_04.txt |
AC |
53 ms |
43672 KiB |
| 01_random_05.txt |
AC |
75 ms |
62544 KiB |
| 01_random_06.txt |
AC |
100 ms |
81552 KiB |
| 01_random_07.txt |
AC |
134 ms |
105116 KiB |
| 01_random_08.txt |
AC |
17 ms |
15824 KiB |
| 01_random_09.txt |
AC |
95 ms |
73768 KiB |
| 01_random_10.txt |
AC |
4 ms |
5288 KiB |
| 01_random_11.txt |
AC |
29 ms |
25408 KiB |
| 01_random_12.txt |
AC |
41 ms |
35476 KiB |
| 01_random_13.txt |
AC |
137 ms |
104976 KiB |
| 01_random_14.txt |
AC |
65 ms |
52896 KiB |
| 01_random_15.txt |
AC |
34 ms |
29136 KiB |
| 01_random_16.txt |
AC |
134 ms |
104984 KiB |
| 01_random_17.txt |
AC |
134 ms |
104948 KiB |
| 01_random_18.txt |
AC |
133 ms |
104912 KiB |
| 01_random_19.txt |
AC |
133 ms |
104980 KiB |