# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969588 | Amaarsaa | Bitaro the Brave (JOI19_ho_t1) | C++14 | 539 ms | 134232 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;
using ll = long long ;
vector < ll > O[3002], I[3002];
vector < pair < ll, ll > > J;
ll A[3003][3003];
int main() {
// freopen("moocast.in", "r", stdin);
// freopen("moocast.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
ll t, n, m, ans, s, sum, x, y, r, p, i, j;
cin >> n >> m;
for (i = 1; i <= n; i ++) {
string str;
cin >> str;
for (j = 1; j <= m; j ++) {
if ( str[j - 1] == 'O') {
O[i].push_back(j);
}
if ( str[j - 1] == 'I') {
I[j].push_back(i);
}
if ( str[j - 1] == 'J') {
J.push_back({i, j});
}
}
}
ans = 0;
for ( pair < ll, ll>&P : J) {
x = P.first;
y = P.second;
r = (upper_bound(I[y].begin(), I[y].end(), x) - I[y].begin());
r = I[y].size() - r;
s = upper_bound(O[x].begin(), O[x].end(), y) - O[x].begin();
s = O[x].size() - s;
ans = ans + (r * s);
}
cout << ans << endl;
}
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... |