#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod (10*10*10*10*10*10*10*10*10+7)
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,c[3005][3005],r[3005][3005];
char a[3005][3005];
int32_t main(){
CODE_START;
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=1;j<=m;j++){
c[i][j]=c[i][j-1];
if(a[i][j]=='O'){
c[i][j]++;
}
}
}
for(ll j=1;j<=m;j++)
{
for(ll i=1;i<=n;i++)
{
r[i][j]=r[i-1][j];
if(a[i][j]=='I'){
r[i][j]++;
}
}
}
ll ans=0;
for(ll i=1;i<=n;i++)
{
for(ll j=1;j<=m;j++)
{
if(a[i][j]=='J'){
ans+=max(0ll,(c[i][m]-c[i][j-1])*(r[n][j]-r[i-1][j]));
}
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
2 ms |
1644 KB |
Output is correct |
9 |
Correct |
1 ms |
1644 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
2 ms |
1644 KB |
Output is correct |
12 |
Correct |
1 ms |
1644 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
2 ms |
1644 KB |
Output is correct |
9 |
Correct |
1 ms |
1644 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
2 ms |
1644 KB |
Output is correct |
12 |
Correct |
1 ms |
1644 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
12 ms |
9068 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
6 ms |
5356 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
15 ms |
9964 KB |
Output is correct |
19 |
Correct |
11 ms |
9836 KB |
Output is correct |
20 |
Correct |
11 ms |
9836 KB |
Output is correct |
21 |
Correct |
14 ms |
9964 KB |
Output is correct |
22 |
Correct |
11 ms |
9836 KB |
Output is correct |
23 |
Correct |
11 ms |
9836 KB |
Output is correct |
24 |
Correct |
14 ms |
9964 KB |
Output is correct |
25 |
Correct |
13 ms |
9836 KB |
Output is correct |
26 |
Correct |
12 ms |
9836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
1644 KB |
Output is correct |
6 |
Correct |
2 ms |
1644 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
2 ms |
1644 KB |
Output is correct |
9 |
Correct |
1 ms |
1644 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
2 ms |
1644 KB |
Output is correct |
12 |
Correct |
1 ms |
1644 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
12 ms |
9068 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
6 ms |
5356 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
15 ms |
9964 KB |
Output is correct |
19 |
Correct |
11 ms |
9836 KB |
Output is correct |
20 |
Correct |
11 ms |
9836 KB |
Output is correct |
21 |
Correct |
14 ms |
9964 KB |
Output is correct |
22 |
Correct |
11 ms |
9836 KB |
Output is correct |
23 |
Correct |
11 ms |
9836 KB |
Output is correct |
24 |
Correct |
14 ms |
9964 KB |
Output is correct |
25 |
Correct |
13 ms |
9836 KB |
Output is correct |
26 |
Correct |
12 ms |
9836 KB |
Output is correct |
27 |
Correct |
466 ms |
158700 KB |
Output is correct |
28 |
Correct |
20 ms |
26348 KB |
Output is correct |
29 |
Correct |
21 ms |
13932 KB |
Output is correct |
30 |
Correct |
2 ms |
876 KB |
Output is correct |
31 |
Correct |
355 ms |
131564 KB |
Output is correct |
32 |
Correct |
449 ms |
159084 KB |
Output is correct |
33 |
Correct |
439 ms |
158700 KB |
Output is correct |
34 |
Correct |
441 ms |
152428 KB |
Output is correct |
35 |
Correct |
458 ms |
159340 KB |
Output is correct |
36 |
Correct |
439 ms |
158572 KB |
Output is correct |
37 |
Correct |
519 ms |
159212 KB |
Output is correct |
38 |
Correct |
322 ms |
130924 KB |
Output is correct |
39 |
Correct |
317 ms |
130924 KB |
Output is correct |