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 int ll;
#define pb push_back
#define pob pop_back
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vc vector<char>
#define vvc vector<vc>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int h, w;
ll counter = 0;
cin >> h >> w;
vvc data(h, vc(w));
vvi a(h, vi(w)), b(w, vi(h));
for(int i = 0; i < h; i++)
for(int j = 0; j < w; j++)
cin >> data[i][j];
for(int i = 0; i < h; i++){
int ashkan = 0;
for(int j = w - 1; j >= 0; j--){
if(data[i][j] == 'O')
ashkan++;
a[i][j] = ashkan;
}
}
for(int i = 0; i < w; i++){
int ashkan = 0;
for(int j = h - 1; j >= 0; j--){
if(data[j][i] == 'I')
ashkan++;
b[i][j] = ashkan;
}
}
for(int i = 0; i < h; i++)
for(int j = 0; j < w; j++)
if(data[i][j] == 'J')
counter += (ll)(a[i][j] * b[j][i]);
cout << counter;
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... |