| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1352127 | nguthianmangcay | Bitaro the Brave (JOI19_ho_t1) | C++20 | 270 ms | 211816 KiB |
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+3;
const long long inf=1e18+3;
#define ll long long
#define fi first
#define se second
#define VOI void
#define int long long
int a[N][N];
ll cnt[2][N][N];
VOI jiangly(){
int h,w;
cin>>h>>w;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
char x;
cin>>x;
if(x == 'J'){
a[i][j] = 1;
}
else if(x == 'O'){
a[i][j] = 2;
}
else if(x == 'I'){
a[i][j] = 3;
}
}
}
for(int i=h;i>=1;i--){
for(int j=w;j>=1;j--){
cnt[0][i][j] = cnt[0][i][j+1] + (a[i][j] == 2);
cnt[1][j][i] = cnt[1][j][i+1] + (a[i][j] == 3);
}
}
ll ans = 0;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(a[i][j] == 1){
// cout<<cnt[0][i][j+1]<<" "<<cnt[1][j][i+1]<<"\n";
ans += (cnt[0][i][j+1] * cnt[1][j][i+1]);
}
}
}
cout<<ans;
}
int32_t main(){
cin.tie(0)->sync_with_stdio(0);
if(fopen("QUANSENSEI.inp","r")){
freopen("O(0).inp","r",stdin);
}
// if(fopen("input.txt","r")){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// }
jiangly();
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\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... | ||||
