이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl
using namespace std;
typedef long long ll;
int n, m;
int dpo[3003][3003];
int dpi[3003][3003];
char mat[3003][3003];
int main(){
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
cin.tie(0); ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
cin >> mat[i][j];
}
}
for (int i = 0; i < n; i++){
int sum = 0;
for (int j = m-1; j >= 0; j--){
sum += mat[i][j] == 'O';
dpo[i][j] = sum;
}
}
for (int j = 0; j < m; j++){
int sum = 0;
for (int i = n-1; i >= 0; i--){
sum += mat[i][j] == 'I';
dpi[i][j] = sum;
}
}
ll ans = 0;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (mat[i][j] == 'J') ans += (ll)dpi[i][j]*(ll)dpo[i][j];
}
}
cout << ans << endl;
}
//by ekrem
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |