#include<bits/stdc++.h>
using namespace std;
const int nmax=3e3+42;
int n,m;
int sums[3][nmax][nmax];
int mem[nmax][nmax];
int ask(int type,int x1,int y1,int x2,int y2)
{
if(x1>x2||y1>y2)return 0;
return sums[type][x2][y2]-sums[type][x1-1][y2]-sums[type][x2][y1-1]+sums[type][x1-1][y1-1];
}
int main()
{
scanf("%i%i",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
char c=getchar();
while(c!='J'&&c!='O'&&c!='I')c=getchar();
if(c=='J')sums[0][i][j]=1,mem[i][j]=0;
else if(c=='O')sums[1][i][j]=1,mem[i][j]=1;
else sums[2][i][j]=1,mem[i][j]=2;
}
for(int type=0;type<3;type++)
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
sums[type][i][j]=sums[type][i-1][j]+sums[type][i][j-1]-sums[type][i-1][j-1]+sums[type][i][j];
long long ret=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(mem[i][j]==0)ret=ret+ask(1,i,j+1,i,m)*ask(2,i+1,j,n,j);
printf("%lld\n",ret);
return 0;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i",&n,&m);
~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
2048 KB |
Output is correct |
6 |
Correct |
5 ms |
2048 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
5 ms |
2048 KB |
Output is correct |
9 |
Correct |
6 ms |
2048 KB |
Output is correct |
10 |
Correct |
5 ms |
1916 KB |
Output is correct |
11 |
Correct |
6 ms |
2048 KB |
Output is correct |
12 |
Correct |
5 ms |
2048 KB |
Output is correct |
13 |
Correct |
6 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
2048 KB |
Output is correct |
6 |
Correct |
5 ms |
2048 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
5 ms |
2048 KB |
Output is correct |
9 |
Correct |
6 ms |
2048 KB |
Output is correct |
10 |
Correct |
5 ms |
1916 KB |
Output is correct |
11 |
Correct |
6 ms |
2048 KB |
Output is correct |
12 |
Correct |
5 ms |
2048 KB |
Output is correct |
13 |
Correct |
6 ms |
1920 KB |
Output is correct |
14 |
Correct |
17 ms |
11520 KB |
Output is correct |
15 |
Correct |
8 ms |
7168 KB |
Output is correct |
16 |
Correct |
11 ms |
6528 KB |
Output is correct |
17 |
Correct |
6 ms |
640 KB |
Output is correct |
18 |
Correct |
18 ms |
12408 KB |
Output is correct |
19 |
Correct |
17 ms |
12288 KB |
Output is correct |
20 |
Correct |
17 ms |
12288 KB |
Output is correct |
21 |
Correct |
19 ms |
12416 KB |
Output is correct |
22 |
Correct |
17 ms |
12288 KB |
Output is correct |
23 |
Correct |
17 ms |
12288 KB |
Output is correct |
24 |
Correct |
20 ms |
12416 KB |
Output is correct |
25 |
Correct |
18 ms |
12288 KB |
Output is correct |
26 |
Correct |
18 ms |
12288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
6 ms |
2048 KB |
Output is correct |
6 |
Correct |
5 ms |
2048 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
5 ms |
2048 KB |
Output is correct |
9 |
Correct |
6 ms |
2048 KB |
Output is correct |
10 |
Correct |
5 ms |
1916 KB |
Output is correct |
11 |
Correct |
6 ms |
2048 KB |
Output is correct |
12 |
Correct |
5 ms |
2048 KB |
Output is correct |
13 |
Correct |
6 ms |
1920 KB |
Output is correct |
14 |
Correct |
17 ms |
11520 KB |
Output is correct |
15 |
Correct |
8 ms |
7168 KB |
Output is correct |
16 |
Correct |
11 ms |
6528 KB |
Output is correct |
17 |
Correct |
6 ms |
640 KB |
Output is correct |
18 |
Correct |
18 ms |
12408 KB |
Output is correct |
19 |
Correct |
17 ms |
12288 KB |
Output is correct |
20 |
Correct |
17 ms |
12288 KB |
Output is correct |
21 |
Correct |
19 ms |
12416 KB |
Output is correct |
22 |
Correct |
17 ms |
12288 KB |
Output is correct |
23 |
Correct |
17 ms |
12288 KB |
Output is correct |
24 |
Correct |
20 ms |
12416 KB |
Output is correct |
25 |
Correct |
18 ms |
12288 KB |
Output is correct |
26 |
Correct |
18 ms |
12288 KB |
Output is correct |
27 |
Correct |
372 ms |
151544 KB |
Output is correct |
28 |
Correct |
29 ms |
38144 KB |
Output is correct |
29 |
Correct |
27 ms |
13312 KB |
Output is correct |
30 |
Correct |
6 ms |
896 KB |
Output is correct |
31 |
Correct |
285 ms |
125560 KB |
Output is correct |
32 |
Correct |
317 ms |
151928 KB |
Output is correct |
33 |
Correct |
301 ms |
151544 KB |
Output is correct |
34 |
Correct |
311 ms |
145528 KB |
Output is correct |
35 |
Correct |
331 ms |
152056 KB |
Output is correct |
36 |
Correct |
295 ms |
151544 KB |
Output is correct |
37 |
Correct |
377 ms |
152184 KB |
Output is correct |
38 |
Correct |
227 ms |
125432 KB |
Output is correct |
39 |
Correct |
218 ms |
125048 KB |
Output is correct |