#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll ans=0;
const int MAX=3005;
char tab[MAX][MAX];
int sufo[MAX][MAX];
int sufi[MAX][MAX];
int32_t main()
{
BOOST;
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>tab[i][j];
for (int i=1;i<=n;i++)
for (int j=m;j>=1;j--)
sufo[i][j]=sufo[i][j+1]+(tab[i][j]=='O');
for (int i=1;i<=m;i++)
for (int j=n;j>=1;j--)
sufi[i][j]=sufi[i][j+1]+(tab[j][i]=='I');
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (tab[i][j]=='J')
ans+=(ll)sufo[i][j]*sufi[j][i];
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
7040 KB |
Output is correct |
15 |
Correct |
7 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5248 KB |
Output is correct |
17 |
Correct |
6 ms |
1664 KB |
Output is correct |
18 |
Correct |
15 ms |
8064 KB |
Output is correct |
19 |
Correct |
14 ms |
7936 KB |
Output is correct |
20 |
Correct |
14 ms |
7936 KB |
Output is correct |
21 |
Correct |
15 ms |
8064 KB |
Output is correct |
22 |
Correct |
14 ms |
7808 KB |
Output is correct |
23 |
Correct |
14 ms |
7936 KB |
Output is correct |
24 |
Correct |
15 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7808 KB |
Output is correct |
26 |
Correct |
14 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1536 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1408 KB |
Output is correct |
14 |
Correct |
13 ms |
7040 KB |
Output is correct |
15 |
Correct |
7 ms |
3328 KB |
Output is correct |
16 |
Correct |
10 ms |
5248 KB |
Output is correct |
17 |
Correct |
6 ms |
1664 KB |
Output is correct |
18 |
Correct |
15 ms |
8064 KB |
Output is correct |
19 |
Correct |
14 ms |
7936 KB |
Output is correct |
20 |
Correct |
14 ms |
7936 KB |
Output is correct |
21 |
Correct |
15 ms |
8064 KB |
Output is correct |
22 |
Correct |
14 ms |
7808 KB |
Output is correct |
23 |
Correct |
14 ms |
7936 KB |
Output is correct |
24 |
Correct |
15 ms |
8064 KB |
Output is correct |
25 |
Correct |
13 ms |
7808 KB |
Output is correct |
26 |
Correct |
14 ms |
7936 KB |
Output is correct |
27 |
Correct |
290 ms |
86008 KB |
Output is correct |
28 |
Correct |
14 ms |
16768 KB |
Output is correct |
29 |
Correct |
30 ms |
17400 KB |
Output is correct |
30 |
Correct |
11 ms |
9856 KB |
Output is correct |
31 |
Correct |
211 ms |
72824 KB |
Output is correct |
32 |
Correct |
255 ms |
88312 KB |
Output is correct |
33 |
Correct |
273 ms |
88312 KB |
Output is correct |
34 |
Correct |
239 ms |
79480 KB |
Output is correct |
35 |
Correct |
285 ms |
88184 KB |
Output is correct |
36 |
Correct |
265 ms |
88312 KB |
Output is correct |
37 |
Correct |
301 ms |
88568 KB |
Output is correct |
38 |
Correct |
170 ms |
72568 KB |
Output is correct |
39 |
Correct |
200 ms |
72404 KB |
Output is correct |