This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 123;
int n,m;
char a[3100][3100];
int so[N][N],si[N][N];
void test(){
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = m;j >= 1;j--){
so[i][j] = so[i][j + 1] + (a[i][j] == 'O');
}
}
for(int i = 1;i <= m;i++){
for(int j = n;j >= 1;j--){
si[j][i] = si[j + 1][i] + (a[j][i] == 'I');
}
}
ll res = 0;
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;j++){
if(a[i][j] == 'J'){
res += so[i][j + 1] * 1ll * si[i + 1][j];
}
}
}
cout << res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) test();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |