이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int sz = 3e3 + 9;
vector <int> os[sz], is[sz];
char a[sz][sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int h, w;
cin >> h >> w;
int r = 0;
for (int i = 1; i <= h; i ++) {
for (int j = 1; j <= w; j ++) {
cin >> a[i][j];
if ('O' == a[i][j]) {
os[i].push_back(j);
} else if ('I' == a[i][j]) {
is[j].push_back(i);
}
}
}
for (int i = 1; i <= h; i ++) {
for (int j = 1; j <= w; j ++) {
if ('J' == a[i][j]) {
int oc = os[i].end() - upper_bound(begin(os[i]), end(os[i]), j);
int ic = is[j].end() - upper_bound(begin(is[j]), end(is[j]), i);
r += oc * ic;
}
}
}
cout << r << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |