# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118784 | horezushol | Bitaro the Brave (JOI19_ho_t1) | C++14 | 219 ms | 159600 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>
#define F first
#define S second
#define SZ(x) lint((x).size())
const char nl = '\n';
using lint = long long;
using namespace std;
void hotline(string name) {
#ifndef ONLINE_JUDGE
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
#endif
}
const lint N = 3010;
char a[N][N];
lint n, m;
lint prefo[N][N]; // in string
lint prefi[N][N]; // in column
lint geto(lint i, lint l, lint r) {
lint f = prefo[i][r] - prefo[i][l-1];
return f;
}
lint geti(lint j, lint l, lint r) {
lint f = prefi[r][j] - prefi[l-1][j];
return f;
}
void verkefni() {
cin >> n >> m;
for (lint i = 1; i <= n; i ++) {
for (lint j = 1; j <= m; j ++) {
cin >> a[i][j];
prefo[i][j] = prefo[i][j-1] + (a[i][j] == 'O');
}
}
for (lint i = 1; i <= m; i ++) {
for (lint j = 1; j <= n; j ++) {
prefi[j][i] = prefi[j-1][i] + (a[j][i] == 'I');
}
}
// for (lint i = 1; i <= n; i ++) {
// for (lint j = 1; j <= m; j ++) {
// cout << prefi[i][j] << " ";
// }
// cout << nl;
// }
lint tot = 0;
for (lint i = 1; i <= n; i ++) {
for (lint j = 1; j <= m; j ++) {
if (a[i][j] == 'J') {
tot += geto(i,j,m) * geti(j,i,n);
}
}
}
cout << tot;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// hotline("t");
lint tst = 1;
// cin >> tst;
while (tst --) {
verkefni();
cout << nl;
}
}
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... |