# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1118783 | horezushol | Bitaro the Brave (JOI19_ho_t1) | C++14 | 9 ms | 13920 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) int((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 int N = 3010;
char a[N][N];
int n, m;
int prefo[N][N]; // in string
int prefi[N][N]; // in column
int geto(int i, int l, int r) {
int f = prefo[i][r] - prefo[i][l-1];
return f;
}
int geti(int j, int l, int r) {
int f = prefi[r][j] - prefi[l-1][j];
return f;
}
void verkefni() {
cin >> n >> m;
for (int i = 1; i <= n; i ++) {
for (int j = 1; j <= m; j ++) {
cin >> a[i][j];
prefo[i][j] = prefo[i][j-1] + (a[i][j] == 'O');
}
}
for (int i = 1; i <= m; i ++) {
for (int j = 1; j <= n; j ++) {
prefi[j][i] = prefi[j-1][i] + (a[j][i] == 'I');
}
}
// for (int i = 1; i <= n; i ++) {
// for (int j = 1; j <= m; j ++) {
// cout << prefi[i][j] << " ";
// }
// cout << nl;
// }
int tot = 0;
for (int i = 1; i <= n; i ++) {
for (int 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");
int 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... |