이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define x1 x1228
#define y1 y1228
#define left left228
#define right right228
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl;
#define TIME (ld)clock()/CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 3000 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll inf = 1e18;
mt19937 rnd(time(0));
int h, w;
string a[maxn];
int row[maxn][maxn];
int col[maxn][maxn];
void solve() {
cin >> h >> w;
for (int i = 0; i < h; ++i) {
cin >> a[i];
}
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) row[i][j + 1] = row[i][j] + (a[i][j] == 'O');
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h; ++i) {
col[j][i + 1] = col[j][i] + (a[i][j] == 'I');
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (a[i][j] == 'J') ans += (row[i][w] - row[i][j + 1]) * (col[j][h] - col[j][i + 1]);
}
}
cout << ans;
}
signed main() {
#ifdef LOCAL
freopen("TASK.in", "r", stdin);
freopen("TASK.out", "w", stdout);
#else
#endif // LOCAL
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.precision(20);
cout << fixed;
int t = 1;
for (int i = 0; i < t; ++i) {
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... |