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 ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;
ll h,w;
char s[3001][3001];
ll row[3001][3001];
ll col[3001][3001];
int main(){
/*freopen("tavsan.gir", "r", stdin);
freopen("tavsan.cik", "w", stdout);
*/ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> h >> w;
ref(i,1,h)ref(j,1,w)cin >> s[i][j];
ref(i,1,h){
for(ll j=w;j>=1;--j){
row[i][j]=row[i][j+1]+(s[i][j]=='O');
}
}
ref(i,1,w){
for(ll j=h;j>=1;--j){
col[j][i]=col[j+1][i]+(s[j][i]=='I');
}
}
ll ans=0;
ref(i,1,h){
ref(j,1,w){
if(s[i][j]=='J'){
ans+=row[i][j+1]*col[i+1][j];
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |