#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
ll n, m;
char a[3010][3010];
ll O[3010][3010], I[3100][3010];
ll ans;
int main(void)
{
fastio
cin >> n >> m;
for(ll i = 1 ; i <= n ; i++)
{
for(ll j = 1 ; j <= m ; j++)
cin >> a[i][j];
}
for(ll i = 1 ; i <= n ; i++)
{
for(ll j = m ; j >= 1 ; j--)
{
O[i][j] = O[i][j + 1];
if(a[i][j] == 'O')
O[i][j]++;
}
}
for(ll j = 1 ; j <= m ; j++)
{
for(ll i = n ; i >= 1 ; i--)
{
I[i][j] = I[i + 1][j];
if(a[i][j] == 'I')
I[i][j]++;
}
}
for(ll i = 1 ; i <= n ; i++)
{
for(ll j = 1 ; j <= m ; j++)
{
if(a[i][j] == 'J')
ans += I[i][j] * O[i][j];
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1360 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1360 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
11 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
5068 KB |
Output is correct |
16 |
Correct |
4 ms |
5240 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
11 ms |
10016 KB |
Output is correct |
19 |
Correct |
10 ms |
9804 KB |
Output is correct |
20 |
Correct |
7 ms |
9812 KB |
Output is correct |
21 |
Correct |
9 ms |
9940 KB |
Output is correct |
22 |
Correct |
11 ms |
9812 KB |
Output is correct |
23 |
Correct |
10 ms |
9684 KB |
Output is correct |
24 |
Correct |
12 ms |
9972 KB |
Output is correct |
25 |
Correct |
8 ms |
9812 KB |
Output is correct |
26 |
Correct |
8 ms |
9796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1360 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
11 ms |
8916 KB |
Output is correct |
15 |
Correct |
3 ms |
5068 KB |
Output is correct |
16 |
Correct |
4 ms |
5240 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
11 ms |
10016 KB |
Output is correct |
19 |
Correct |
10 ms |
9804 KB |
Output is correct |
20 |
Correct |
7 ms |
9812 KB |
Output is correct |
21 |
Correct |
9 ms |
9940 KB |
Output is correct |
22 |
Correct |
11 ms |
9812 KB |
Output is correct |
23 |
Correct |
10 ms |
9684 KB |
Output is correct |
24 |
Correct |
12 ms |
9972 KB |
Output is correct |
25 |
Correct |
8 ms |
9812 KB |
Output is correct |
26 |
Correct |
8 ms |
9796 KB |
Output is correct |
27 |
Correct |
323 ms |
158772 KB |
Output is correct |
28 |
Correct |
12 ms |
26324 KB |
Output is correct |
29 |
Correct |
21 ms |
13912 KB |
Output is correct |
30 |
Correct |
1 ms |
724 KB |
Output is correct |
31 |
Correct |
227 ms |
131536 KB |
Output is correct |
32 |
Correct |
291 ms |
159244 KB |
Output is correct |
33 |
Correct |
286 ms |
158788 KB |
Output is correct |
34 |
Correct |
237 ms |
152604 KB |
Output is correct |
35 |
Correct |
275 ms |
159260 KB |
Output is correct |
36 |
Correct |
298 ms |
158796 KB |
Output is correct |
37 |
Correct |
320 ms |
159320 KB |
Output is correct |
38 |
Correct |
210 ms |
130820 KB |
Output is correct |
39 |
Correct |
197 ms |
131024 KB |
Output is correct |