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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m; cin >> n >> m;
vector<str> v(n);
for(str &s: v) cin >> s;
vector<ll> ingots(m, 0LL);
ll ans = 0;
for(int i = n-1; i >= 0; i--){
ll orbs = 0;
for(int j = m-1; j >= 0; j--){
if(v[i][j] == 'J') ans+=orbs*ingots[j];
if(v[i][j] == 'O') orbs++;
if(v[i][j] == 'I') ingots[j]++;
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |