# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1258762 | duynam | Bitaro the Brave (JOI19_ho_t1) | C++20 | 118 ms | 150456 KiB |
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn=3005;
const int inf=1e18;
char a[maxn][maxn];
int res=0;
int b[maxn][maxn];
int c[maxn][maxn];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
if(fopen(".inp","r")){
freopen(".inp","r",stdin);
freopen(".out","w",stdout);
}
int h,w;
cin>>h>>w;
for(int i=1;i<=h;i++){
string s;
cin>>s;
s="*"+s;
for(int j=1;j<=w;j++){
a[i][j]=s[j];
b[i][j]=b[i-1][j]+1*(s[j]=='I');
c[i][j]=c[i][j-1]+1*(s[j]=='O');
}
}
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(a[i][j]=='J'){
res+=(b[h][j]-b[i][j])*(c[i][w]-c[i][j]);
}
}
}
cout<<res<<'\n';
}
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... |