이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e3 + 5;
int n, m, arr[N][N];
vector<int> row[N][5], col[N][5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ch;
cin >> ch;
if (ch == 'J') arr[i][j] = 0;
else if (ch == 'O') arr[i][j] = 1;
else arr[i][j] = 2;
row[i][arr[i][j]].push_back(j);
col[j][arr[i][j]].push_back(i);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 3; j++) {
sort(row[i][j].begin(), row[i][j].end());
}
}
for (int j = 1; j <= m; j++) {
for (int i = 0; i < 3; i++) {
sort(col[j][i].begin(), col[j][i].end());
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (arr[i][j]) continue;
int cntO = row[i][1].end() - upper_bound(row[i][1].begin(), row[i][1].end(), j);
int cntI = col[j][2].end() - upper_bound(col[j][2].begin(), col[j][2].end(), i);
ans += cntO*cntI;
}
}
cout << ans << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |