#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> s(n);
for (auto &o: s) {
cin >> o;
}
vector oki(n, vector<int>(m, 0));
vector oko(n, vector<int>(m, 0));
for (int i = 0; i < m; i++) {
int cnti = 0;
for (int j = n - 1; j >= 0; j--) {
if (s[j][i] == 'I') ++cnti;
else if (s[j][i] == 'J') oki[j][i] = cnti;
}
}
for (int i = 0; i < n; i++) {
int cnto = 0;
for (int j = m - 1; j >= 0; j--) {
if (s[i][j] == 'O') ++cnto;
else if (s[i][j] == 'J') oko[i][j] = cnto;
}
}
ll ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ans += oki[i][j] * oko[i][j];
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |