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;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
char a[3010][3010];
int n, m;
int ing[3010][3010], orb[3010][3010];
int32_t main(){
INIT
cin>>n>>m;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin>>a[i][j];
if(a[i][j]=='I'){
ing[i][j]++;
}
if(a[i][j]=='O'){
orb[i][j]++;
}
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
orb[i][j]=orb[i][j-1]+orb[i][j];
}
}
for(int j=1; j<=m; j++){
for(int i=1; i<=n; i++){
ing[i][j]=ing[i-1][j]+ing[i][j];
}
}
int res=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(a[i][j]=='J'){
res+=(ing[n][j]-ing[i][j])*(orb[i][m]-orb[i][j]);
}
}
}
cout<<res;
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... |