//Pantyhose(black) + glasses = infinity
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"
const int MAX_N = 3002;
int m, n;
char a[MAX_N][MAX_N];
int row[MAX_N][MAX_N], col[MAX_N][MAX_N];
void readInput() {
cin >> m >> n;
for (int i=1; i<=m; ++i) {
for (int j=1; j<=n; ++j)
cin >> a[i][j];
}
}
void solve() {
for (int i=1; i<=m; ++i) {
for (int j=n; j>=1; --j)
row[i][j] = row[i][j+1] + (a[i][j]=='O');
}
for (int j=1; j<=n; ++j) {
for (int i=m; i>=1; --i)
col[i][j] = col[i+1][j] + (a[i][j]=='I');
}
int64_t res = 0;
for (int i=1; i<=m; ++i) {
for (int j=1; j<=n; ++j) {
if (a[i][j]=='J')
res += row[i][j] * col[j][j];
}
}
cout << res;
}
int main() {
#ifdef GLASSES_GIRL
freopen(FILE_NAME".in", "r", stdin);
freopen(FILE_NAME".out", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0);
readInput();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |