이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define REV(i, b, a) for(int i = (b); i >= (a); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define ll long long
#define fi first
#define se second
#define int long long
using namespace std;
const int N = 3005;
int n, m;
int a[N][N];
int d1[N][N], d2[N][N];
void solve(int tc) {
cin >> n >> m;
char ch;
FOR(i, 1, n) FOR(j, 1, m) {
cin >> ch;
a[i][j] = ch == 'J' ? 0 : ch == 'O' ? 1 : 2;
}
int ans = 0;
REV(i, n, 1) {
REV(j, m, 1) {
d1[i][j] = d1[i][j + 1] + (a[i][j] == 1);
d2[i][j] = d2[i + 1][j] + (a[i][j] == 2);
if(a[i][j] == 0) ans += d1[i][j] * d2[i][j];
}
}
cout << ans << '\n';
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int tc = 1;
// cin >> tc;
for(int i = 1; i <= tc; ++i) solve(tc);
return (0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |