# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
716191 | shoryu386 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 197 ms | 274432 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>
using namespace std;
#define int long long
main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
char arr[n][m];
for (int x = n-1; x > -1; x--){
for (int y = 0; y < m; y++) cin >> arr[x][y];
}
int OpsumHori[n][m], OpsumVert[n][m], IpsumHori[n][m], IpsumVert[n][m];
for (int x = 0; x < n; x++){
OpsumHori[x][m-1] = (arr[x][m-1] == 'O');
IpsumHori[x][m-1] = (arr[x][m-1] == 'I');
for (int y = m-2; y > -1; y--){
OpsumHori[x][y] = OpsumHori[x][y+1] + (arr[x][y] == 'O');
IpsumHori[x][y] = IpsumHori[x][y+1] + (arr[x][y] == 'I');
}
}
for (int y = 0; y < m; y++){
OpsumVert[0][y] = (arr[0][y] == 'O');
IpsumVert[0][y] = (arr[0][y] == 'I');
for (int x = 1; x < n; x++){
OpsumVert[x][y] = OpsumVert[x-1][y] + (arr[x][y] == 'O');
IpsumVert[x][y] = IpsumVert[x-1][y] + (arr[x][y] == 'I');
}
}
int ans = 0;
for (int x = 0; x < n; x++){
for (int y = 0; y < m; y++){
if (arr[x][y] == 'J') ans += OpsumHori[x][y] * IpsumVert[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... |