#include <bits/stdc++.h>
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {
return o << '(' << p.first << ", " << p.second << ')';
}
template<class T>
auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o) {
o << '{';
bool first = true;
for (const auto& e : x) {
if (!first) {
o << ", ";
}
o << e;
first = false;
}
return o << '}';
}
#define DEBUG
#ifdef DEBUG
#define fastio()
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#define check(x) if (!(x)) { cerr << "Check failed: " << #x << " in line " << __LINE__ << endl; exit(1); }
#else
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0);
#define debug(...)
#define check(x)
#endif
typedef long long ll;
#define pi pair<int, int>
#define pl pair<ll, ll>
#define st first
#define nd second
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
int tab[3010][3010];
int sumd[3010][3010];
int sump[3010][3010];
void solve() {
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++) {
string c;
cin >> c;
for(int j = 1; j <= m; j++) {
if(c[j - 1] == 'O') {
tab[i][j] = 1;
}
if(c[j - 1] == 'I') {
tab[i][j] = 2;
}
}
}
for(int j = 1; j <= m; j++) {
for(int i = n; i >= 1; i--) {
sumd[j][i] = sumd[j][i + 1];
if(tab[i][j] == 2) {
sumd[j][i]++;
}
}
}
for(int i = 1; i <= n; i++) {
for(int j = m; j >= 1; j--) {
sump[i][j] = sump[i][j + 1];
if(tab[i][j] == 1) {
sump[i][j]++;
}
}
}
ll ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(!tab[i][j]) {
ans += sump[i][j + 1] * sumd[j][i + 1];
}
}
}
cout << ans << '\n';
}
int main() {
fastio();
int t;
//cin >> t;
t = 1;
while(t--) {
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1464 KB |
Output is correct |
8 |
Correct |
1 ms |
1596 KB |
Output is correct |
9 |
Correct |
2 ms |
1460 KB |
Output is correct |
10 |
Correct |
1 ms |
1464 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1464 KB |
Output is correct |
8 |
Correct |
1 ms |
1596 KB |
Output is correct |
9 |
Correct |
2 ms |
1460 KB |
Output is correct |
10 |
Correct |
1 ms |
1464 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1464 KB |
Output is correct |
14 |
Correct |
10 ms |
8200 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
6 ms |
5844 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
12 ms |
9480 KB |
Output is correct |
19 |
Correct |
9 ms |
9136 KB |
Output is correct |
20 |
Correct |
9 ms |
9132 KB |
Output is correct |
21 |
Correct |
13 ms |
9532 KB |
Output is correct |
22 |
Correct |
9 ms |
9044 KB |
Output is correct |
23 |
Correct |
9 ms |
9132 KB |
Output is correct |
24 |
Correct |
12 ms |
9428 KB |
Output is correct |
25 |
Correct |
11 ms |
9148 KB |
Output is correct |
26 |
Correct |
9 ms |
9044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1620 KB |
Output is correct |
6 |
Correct |
1 ms |
1464 KB |
Output is correct |
7 |
Correct |
1 ms |
1464 KB |
Output is correct |
8 |
Correct |
1 ms |
1596 KB |
Output is correct |
9 |
Correct |
2 ms |
1460 KB |
Output is correct |
10 |
Correct |
1 ms |
1464 KB |
Output is correct |
11 |
Correct |
1 ms |
1620 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1464 KB |
Output is correct |
14 |
Correct |
10 ms |
8200 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
6 ms |
5844 KB |
Output is correct |
17 |
Correct |
1 ms |
1492 KB |
Output is correct |
18 |
Correct |
12 ms |
9480 KB |
Output is correct |
19 |
Correct |
9 ms |
9136 KB |
Output is correct |
20 |
Correct |
9 ms |
9132 KB |
Output is correct |
21 |
Correct |
13 ms |
9532 KB |
Output is correct |
22 |
Correct |
9 ms |
9044 KB |
Output is correct |
23 |
Correct |
9 ms |
9132 KB |
Output is correct |
24 |
Correct |
12 ms |
9428 KB |
Output is correct |
25 |
Correct |
11 ms |
9148 KB |
Output is correct |
26 |
Correct |
9 ms |
9044 KB |
Output is correct |
27 |
Correct |
356 ms |
111280 KB |
Output is correct |
28 |
Correct |
9 ms |
19264 KB |
Output is correct |
29 |
Correct |
24 ms |
18940 KB |
Output is correct |
30 |
Correct |
6 ms |
9812 KB |
Output is correct |
31 |
Correct |
252 ms |
94736 KB |
Output is correct |
32 |
Correct |
261 ms |
112396 KB |
Output is correct |
33 |
Correct |
261 ms |
110052 KB |
Output is correct |
34 |
Correct |
293 ms |
105128 KB |
Output is correct |
35 |
Correct |
281 ms |
110500 KB |
Output is correct |
36 |
Correct |
262 ms |
110276 KB |
Output is correct |
37 |
Correct |
359 ms |
113280 KB |
Output is correct |
38 |
Correct |
174 ms |
93628 KB |
Output is correct |
39 |
Correct |
170 ms |
90864 KB |
Output is correct |