이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<string> arr(n);
for (auto &x : arr) {
cin >> x;
}
vector<vector<int>> O(n, vector<int>(m)), I(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] == 'O') {
O[i][j]++;
} else if (arr[i][j] == 'I') {
I[i][j]++;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = m - 2; j >= 0; j--) {
O[i][j] += O[i][j + 1];
}
}
for (int j = 0; j < m; j++) {
for (int i = n - 2; i >= 0; i--) {
I[i][j] += I[i + 1][j];
}
}
int res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] == 'J') {
res += O[i][j] * I[i][j];
}
}
}
cout << res << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |