이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ll long long
#define ar array
#define vt vector
#define inf INT_MAX
#define lnf LLONG_MAX
const int nxm = int(3e3) + 7;
int h, w;
vt<string> a(nxm);
namespace sub1 {
void solve() {
vt<vt<ll>> c(h, vt<ll> (w, 0));
vt<vt<ll>> c2(h, vt<ll> (w, 0));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (a[i][j] == 'I') {
++c[i][j];
} else if (a[i][j] == 'O') {
++c2[i][j];
}
}
}
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w - 1; ++j) {
c2[i][j + 1] += c2[i][j];
}
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h - 1; ++i) {
c[i + 1][j] += c[i][j];
}
}
ll ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (a[i][j] == 'J') {
ans += (c[h - 1][j] - c[i][j]) * (c2[i][w - 1] - c2[i][j]);
}
}
}
cout << ans << "\n";
}
};
int subtask() {
// if (h <= 100 && w <= 100) {
// return 1;
// } else if (h <= 500 && w <= 100) {
// return 2;
// }
return 1;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> h >> w;
for (int i = 0; i < h; ++i) {
cin >> a[i];
}
if (subtask() == 1) {
sub1::solve();
}
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... |