이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn= 3030;
int n, m;
char mat[maxn][maxn];
int J[maxn][maxn], I[maxn][maxn];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> mat[i][j];
for(int i = 1; i <= n; i++) {
for(int j = m; j; j--) {
J[i][j] = J[i][j+1] + (mat[i][j] == 'O');
}
}
for(int i = n; i; i--) {
for(int j = 1; j <= m; j++) {
I[i][j] = I[i+1][j] + (mat[i][j] == 'I');
}
}
ll ans = 0;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
if(mat[i][j] != 'J') continue;
ans += J[i][j] * I[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... |