# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308250 | Bill_00 | Bitaro the Brave (JOI19_ho_t1) | C++14 | 572 ms | 186652 KiB |
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 pp push
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
char a[3005][3005];
ll dpi[3005][3005];
ll dpo[3005][3005];
vector<pair<int,int> >J;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int h,w;
cin >> h >> w;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cin >> a[i][j];
if(a[i][j]=='J'){
J.pb(mp(i,j));
}
}
}
for(int i=1;i<=w;i++){
for(int j=h;j>=1;j--){
if(a[j][i]=='I'){
dpi[j][i]=dpi[j+1][i]+1;
}
else dpi[j][i]=dpi[j+1][i];
}
}
for(int i=1;i<=h;i++){
for(int j=w;j>=1;j--){
if(a[i][j]=='O'){
dpo[i][j]=dpo[i][j+1]+1;
}
else dpo[i][j]=dpo[i][j+1];
}
}
ll ans=0;
for(int i=0;i<J.size();i++){
int x=J[i].ff;
int y=J[i].ss;
ans+=(dpo[x][y]*dpi[x][y]);
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |