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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAXI (int) 1e6
ll a[MAXI];
ll si[MAXI];
ll r[MAXI];
ll maxi = 0;
ll sum = 0;
void solve(){
int h,w; cin >> h >> w;
char mat[h][w];
vector<int> down(w,0);
vector<int> right(h,0);
for(int i = 0;i<h;i++){
for(int j =0;j<w;j++){
cin >> mat[i][j];
if(mat[i][j] == 'I') down[j]++;
if(mat[i][j] == 'O') right[i]++;
}
}
for(int i = 0;i<h;i++){
for(int j =0;j<w;j++){
if(mat[i][j] == 'I') down[j]--;
if(mat[i][j] == 'O') right[i]--;
if(mat[i][j] == 'J') sum += down[j]*right[i];
}
}
cout << sum;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout << fixed << setprecision(8);
int t = 1;
//cin >> t;
while(t){
solve();
t--;
cout << "\n";
}
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... |