#include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=3005;
char a[N][N];
int po[N][N],pi[N][N];
void solve()
{
int n,m;
cin >> n >> m;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin >> a[i][j];
ll ans=0;
for(int i=n;i>=1;i--) for(int j=m;j>=1;j--)
{
po[i][j]=po[i][j+1];
pi[i][j]=pi[i+1][j];
if(a[i][j]=='J') ans+=po[i][j]*pi[i][j];
else if(a[i][j]=='O') po[i][j]++;
else pi[i][j]++;
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("hanhhhh.inp","r",stdin);
//freopen("hanhhhh.out","w",stdout);
int t=1;
//cin >> t;
while(t--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
5 ms |
13660 KB |
Output is correct |
15 |
Correct |
1 ms |
8792 KB |
Output is correct |
16 |
Correct |
3 ms |
7772 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
5 ms |
13916 KB |
Output is correct |
19 |
Correct |
4 ms |
13916 KB |
Output is correct |
20 |
Correct |
3 ms |
13660 KB |
Output is correct |
21 |
Correct |
5 ms |
13916 KB |
Output is correct |
22 |
Correct |
3 ms |
13660 KB |
Output is correct |
23 |
Correct |
4 ms |
13656 KB |
Output is correct |
24 |
Correct |
5 ms |
13916 KB |
Output is correct |
25 |
Correct |
4 ms |
13840 KB |
Output is correct |
26 |
Correct |
4 ms |
13656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
5 ms |
13660 KB |
Output is correct |
15 |
Correct |
1 ms |
8792 KB |
Output is correct |
16 |
Correct |
3 ms |
7772 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
5 ms |
13916 KB |
Output is correct |
19 |
Correct |
4 ms |
13916 KB |
Output is correct |
20 |
Correct |
3 ms |
13660 KB |
Output is correct |
21 |
Correct |
5 ms |
13916 KB |
Output is correct |
22 |
Correct |
3 ms |
13660 KB |
Output is correct |
23 |
Correct |
4 ms |
13656 KB |
Output is correct |
24 |
Correct |
5 ms |
13916 KB |
Output is correct |
25 |
Correct |
4 ms |
13840 KB |
Output is correct |
26 |
Correct |
4 ms |
13656 KB |
Output is correct |
27 |
Correct |
104 ms |
88124 KB |
Output is correct |
28 |
Correct |
6 ms |
44888 KB |
Output is correct |
29 |
Correct |
6 ms |
9308 KB |
Output is correct |
30 |
Correct |
1 ms |
2648 KB |
Output is correct |
31 |
Correct |
74 ms |
73652 KB |
Output is correct |
32 |
Correct |
81 ms |
88368 KB |
Output is correct |
33 |
Correct |
73 ms |
88916 KB |
Output is correct |
34 |
Correct |
101 ms |
85188 KB |
Output is correct |
35 |
Correct |
73 ms |
88608 KB |
Output is correct |
36 |
Correct |
71 ms |
88400 KB |
Output is correct |
37 |
Correct |
101 ms |
88660 KB |
Output is correct |
38 |
Correct |
56 ms |
73808 KB |
Output is correct |
39 |
Correct |
66 ms |
73552 KB |
Output is correct |