# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1258785 | khanhtt | Bitaro the Brave (JOI19_ho_t1) | C++20 | 102 ms | 80020 KiB |
#include <iostream>
using namespace std;
int h,w,O[3005][3005],I[3005][3005];
long long res=0;
string A[3005];
main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cin >> h >> w;
for (int i=1; i<=h; i++){
cin >> A[i];
A[i]="#"+A[i];
}
for (int i=1; i<=h; i++){
for (int j=1; j<=w; j++){
O[i][j]=O[i][j-1]+(A[i][j]=='O');
}
}
for (int i=1; i<=h; i++){
for (int j=1; j<=w; j++){
I[i][j]=I[i-1][j]+(A[i][j]=='I');
}
}
for (int i=1; i<=h; i++){
for (int j=1; j<=w; j++){
if (A[i][j]=='J'){
long long left=O[i][w]-O[i][j],down=I[h][j]-I[i][j];
res+=left*down;
}
}
}
cout << res;
}
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... |