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 yasuho ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
const ll MOD = 1e9+7;
void solve(){
ll r, c; cin >> r >> c;
vector<vector<char>> grid(r+1, vector<char>(c+1));
for(int i=1; i<=r; i++){
for(int j=1; j<=c; j++){
cin >> grid[i][j];
}
}
vector<ll> ingot(c+1, 0);
ll ans = 0;
for(int i=r; i>=1; i--){
ll orb=0;
for(int j=c; j>=1; j--){
if(grid[i][j]=='J'){
// cout << ingot[j] << ' ' << orb << endl;
ans += ingot[j]*orb;
}
if(grid[i][j]=='I') ingot[j]++;
if(grid[i][j]=='O') orb++;
}
}
cout << ans << endl;
return;
}
int main(){
yasuho // remove for interactive problem
ll t;
t = 1;
//cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |