# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404840 | radaiosm7 | Bitaro the Brave (JOI19_ho_t1) | C++98 | 274 ms | 88464 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 X first
#define Y second
int n, m, i, j;
char c, mat[3005][3005];
long long ans;
vector<pair<int, int> > Jew;
int col[3005][3005];
int row[3005][3005];
int main() {
scanf("%d%d", &n, &m);
for (i=0; i < n; ++i) {
scanf("\n%s", mat[i]);
}
for (i=0; i < n; ++i) {
row[i][m-1] = 0;
for (j=m-1; j >= 0; --j) {
row[i][j] = row[i][j+1] + (mat[i][j]=='O');
}
}
for (j=0; j < m; ++j) {
col[n-1][j] = 0;
for (i=n-1; i >= 0; --i) {
col[i][j] = col[i+1][j] + (mat[i][j]=='I');
}
}
ans = 0LL;
for (i=0; i < n; ++i) {
for (j=0; j < m; ++j) {
if (mat[i][j] == 'J') {
ans += (long long)col[i][j]*row[i][j];
}
}
}
printf("%lld\n", ans);
return 0;
}
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... |