이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0)
#endif
int main () {
owo;
int n, m;
cin >> n >> m;
vector <string> s(n);
vector <vector <int>> down(n, vector <int> (m, 0)), r(n, vector <int> (m, 0));
for (int i = 0; i < n; ++i)
cin >> s[i];
for (int i = n - 1; ~i; --i) {
for (int j = 0; j < m; ++j) {
down[i][j] = (i + 1 < n ? down[i + 1][j] : 0) + (s[i][j] == 'I');
}
}
for (int i = 0; i < n; ++i) {
for (int j = m - 1; ~j; --j) {
r[i][j] = (j + 1 < m ? r[i][j + 1] : 0) + (s[i][j] == 'O');
}
}
lli ans = 0;
for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (s[i][j] == 'J')
ans += down[i][j] * r[i][j];
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |