이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 3e3 + 7;
int N, M;
vector<int> vert[MX], hori[MX];
vector<pair<int, int>> pos;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> N >> M;
for(int i = 0; i < N; i++) {
for(int j = 0; j < M; j++) {
char c;
cin >> c;
if(c == 'J') {
pos.push_back({i, j});
} else if(c == 'O') {
hori[i].push_back(j);
} else {
vert[j].push_back(i);
}
}
}
ll ans = 0;
for(auto [x, y] : pos) {
auto p = lower_bound(hori[x].begin(), hori[x].end(), y) - hori[x].begin();
auto q = lower_bound(vert[y].begin(), vert[y].end(), x) - vert[y].begin();
ans += 1LL * (hori[x].size() - p) * (vert[y].size() - q);
}
cout << ans << '\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... |