This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Problem: B - Bitaro the Brave
// Contest: Virtual Judge - THT - Day 14
// URL: https://vjudge.net/contest/571691#problem/B
// Memory Limit: 268 MB
// Time Limit: 1000 ms
#include <bits/stdc++.h>
#define ll long long
#define sp << " "
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
ll n, m, k, t, s;
char c[3005][3005];
ll a[3005][3005][3], b[3005][3005][3];
int main(){
faster;
cin >> n >> m;
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++) cin >> c[i][j];
}
for(ll i = 1; i <= n; i++){
for(ll j = m; j >= 1; j--){
a[i][j][1]=a[i][j+1][1];
if(c[i][j]=='O') a[i][j][1]++;
}
}
for(ll j = 1; j <= m; j++){
for(ll i = n; i >= 1; i--){
b[i][j][2]=b[i+1][j][2];
if(c[i][j]=='I') b[i][j][2]++;
}
}
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
if(c[i][j]=='J')s+=(a[i][j][1]*b[i][j][2]);
}
}
cout << s;
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... |