#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<long long int,long long int>
#define vi vector<long long int >
#define vvi vector<vector< long long int>>
#define MP make_pair
#define PB push_back
#define pb pop_back
#define PF push_front
#define pf pop_front
#define MOD 1000000007
#define MT make_tuple
ll n,m,r[3001][3001],c[3001][3001];
ll ans = 0;
string s[3001];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(ll i=0;i<n;i++)
{
cin>>s[i];
}
for(ll i=0;i<n;i++)
{
for(ll j=0;j<m;j++)
{
r[i][j]=0;
c[i][j]=0;
if(s[i][j]=='O')
r[i][j]++;
if(s[i][j]=='I')
c[i][j]++;
}
r[i][m]=0;
}
for(ll j=0;j<m;j++)
c[n][j]=0;
for(ll i=0;i<n;i++)
{
for(ll j=m-1;j>=0;j--)
{
r[i][j]+=r[i][j+1];
}
}
for(ll j=0;j<m;j++)
{
for(ll i=n-1;i>=0;i--)
c[i][j]+=c[i+1][j];
}
for(ll i=0;i<n;i++)
{
for(ll j=0;j<m;j++)
{
if(s[i][j]=='J')
ans+=r[i][j]*c[i][j];
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1408 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1280 KB |
Output is correct |
11 |
Correct |
5 ms |
1408 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1408 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1280 KB |
Output is correct |
11 |
Correct |
5 ms |
1408 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
7808 KB |
Output is correct |
15 |
Correct |
6 ms |
3968 KB |
Output is correct |
16 |
Correct |
8 ms |
4864 KB |
Output is correct |
17 |
Correct |
5 ms |
640 KB |
Output is correct |
18 |
Correct |
13 ms |
8832 KB |
Output is correct |
19 |
Correct |
11 ms |
8704 KB |
Output is correct |
20 |
Correct |
11 ms |
8704 KB |
Output is correct |
21 |
Correct |
13 ms |
8832 KB |
Output is correct |
22 |
Correct |
11 ms |
8704 KB |
Output is correct |
23 |
Correct |
11 ms |
8704 KB |
Output is correct |
24 |
Correct |
14 ms |
9024 KB |
Output is correct |
25 |
Correct |
11 ms |
8704 KB |
Output is correct |
26 |
Correct |
11 ms |
8704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1408 KB |
Output is correct |
6 |
Correct |
5 ms |
1408 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
5 ms |
1408 KB |
Output is correct |
10 |
Correct |
5 ms |
1280 KB |
Output is correct |
11 |
Correct |
5 ms |
1408 KB |
Output is correct |
12 |
Correct |
5 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1280 KB |
Output is correct |
14 |
Correct |
12 ms |
7808 KB |
Output is correct |
15 |
Correct |
6 ms |
3968 KB |
Output is correct |
16 |
Correct |
8 ms |
4864 KB |
Output is correct |
17 |
Correct |
5 ms |
640 KB |
Output is correct |
18 |
Correct |
13 ms |
8832 KB |
Output is correct |
19 |
Correct |
11 ms |
8704 KB |
Output is correct |
20 |
Correct |
11 ms |
8704 KB |
Output is correct |
21 |
Correct |
13 ms |
8832 KB |
Output is correct |
22 |
Correct |
11 ms |
8704 KB |
Output is correct |
23 |
Correct |
11 ms |
8704 KB |
Output is correct |
24 |
Correct |
14 ms |
9024 KB |
Output is correct |
25 |
Correct |
11 ms |
8704 KB |
Output is correct |
26 |
Correct |
11 ms |
8704 KB |
Output is correct |
27 |
Correct |
327 ms |
158916 KB |
Output is correct |
28 |
Correct |
14 ms |
19840 KB |
Output is correct |
29 |
Correct |
16 ms |
13952 KB |
Output is correct |
30 |
Correct |
5 ms |
896 KB |
Output is correct |
31 |
Correct |
238 ms |
130680 KB |
Output is correct |
32 |
Correct |
261 ms |
159736 KB |
Output is correct |
33 |
Correct |
247 ms |
159480 KB |
Output is correct |
34 |
Correct |
277 ms |
151544 KB |
Output is correct |
35 |
Correct |
272 ms |
159884 KB |
Output is correct |
36 |
Correct |
247 ms |
159352 KB |
Output is correct |
37 |
Correct |
347 ms |
159868 KB |
Output is correct |
38 |
Correct |
189 ms |
130424 KB |
Output is correct |
39 |
Correct |
178 ms |
130172 KB |
Output is correct |