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 ff first
#define ss second
#define ll long long
#define pb push_back
#define pii pair<int,int>
int main(){
ll ans=0;
int n, m;
cin >> n >> m;
char c[n+1][m+1];
vector <pii> pos;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin >> c[i][j];
if(c[i][j] == 'J') pos.pb({i,j});
}
}
for(auto x:pos){
int a=x.ff, b=x.ss, I=0, O=0;
for(int i=a; i<n; i++){
if(c[i][b] == 'I') I++;
}
for(int i=b; i<m; i++){
if(c[a][i] == 'O') O++;
}
ans+=I*O;
}
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... |