이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
using namespace std;
template<typename T1, typename ...T2>
void debug(bool _split, T1 i, T2 ...j) {
if (_split)
cerr << ", ";
cerr << i;
debug(true, j...);
}
#define debug(args...) cout << "Line" << __LINE__ << " : [" << #args << << "] is [" << debug(false, args) << "]" << endl;
typedef pair<int, int> pi;
typedef long long ll;
const int inf = 0x3f3f3f3f, lg = 20;
const ll mod = 1e9 + 7, INF = 0x3f3f3f3f;
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
string s[n];
for (string &i : s)
cin >> i;
int a[n][m], b[n][m];
ll ans = 0;
for (int i = n - 1; ~i; --i)
for (int j = m - 1; ~j; --j) {
a[i][j] = i < n - 1 ? a[i + 1][j] : 0;
a[i][j] += s[i][j] == 'I';
b[i][j] = j < m - 1 ? b[i][j + 1] : 0;
b[i][j] += s[i][j] == 'O';
if (s[i][j] == 'J')
ans += a[i][j] * b[i][j];
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |