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>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define bismillah ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
using namespace std;
const int N = 3007;
char a[N][N];
int prefo[N][N];
int prefi[N][N];
signed main(){
bismillah;
int n, m; cin >> n >> m;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin >> a[i][j];
char c = a[i][j];
prefo[i][j]+=prefo[i][j-1];
prefi[i][j]+=prefi[i-1][j];
if(c=='O'){
prefo[i][j]++;
}else if(c=='I'){
prefi[i][j]++;
}
}
}
int ans = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(a[i][j]=='J'){
int O = prefo[i][m]-prefo[i][j];
int I = prefi[n][j]-prefi[i][j];
ans+=(O*I);
}
}
}
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... |