#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
int col[3002][3002], row[3002][3002];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<string> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
row[i][j] = row[i][j + 1];
row[i][j] += (v[i][j] == 'O');
}
}
for (int j = 0; j < m; j++) {
for (int i = n - 1; i >= 0; i--) {
col[i][j] += col[i + 1][j];
col[i][j] += (v[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
if (v[i][j] == 'J') ans += row[i][j + 1] * col[i + 1][j];
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
2 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
2 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
2 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |