//~ #pragma GCC optimize("Ofast,unroll-loops")
//~ #pragma GCC target("avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fi first
#define se second
#define space " "
#define endl "\n"
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define md 1000000007
#define inf 1000000000
#define li 3005
#define int long long
using namespace std;
int n,m,prei[li][li],preo[li][li],flag;
char c[li][li];
int32_t main(){
scanf("%lld %lld",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf(" %c",&c[i][j]);
}
}
for(int i=n;i>=1;i--){
for(int j=m;j>=1;j--){
if(j!=m){
preo[i][j]=preo[i][j+1];
if(c[i][j+1]=='O') preo[i][j]++;
}
if(i!=n){
prei[i][j]=prei[i+1][j];
if(c[i+1][j]=='I') prei[i][j]++;
}
if(c[i][j]=='J') flag+=prei[i][j]*preo[i][j];
}
}
printf("%lld\n",flag);
return 0;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%lld %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf(" %c",&c[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
5 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
5 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
17 ms |
8912 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
5220 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
19 ms |
9920 KB |
Output is correct |
19 |
Correct |
23 ms |
9728 KB |
Output is correct |
20 |
Correct |
18 ms |
9704 KB |
Output is correct |
21 |
Correct |
23 ms |
9924 KB |
Output is correct |
22 |
Correct |
18 ms |
9756 KB |
Output is correct |
23 |
Correct |
17 ms |
9676 KB |
Output is correct |
24 |
Correct |
21 ms |
9860 KB |
Output is correct |
25 |
Correct |
17 ms |
9752 KB |
Output is correct |
26 |
Correct |
20 ms |
9736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
5 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1364 KB |
Output is correct |
14 |
Correct |
17 ms |
8912 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
5220 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
19 ms |
9920 KB |
Output is correct |
19 |
Correct |
23 ms |
9728 KB |
Output is correct |
20 |
Correct |
18 ms |
9704 KB |
Output is correct |
21 |
Correct |
23 ms |
9924 KB |
Output is correct |
22 |
Correct |
18 ms |
9756 KB |
Output is correct |
23 |
Correct |
17 ms |
9676 KB |
Output is correct |
24 |
Correct |
21 ms |
9860 KB |
Output is correct |
25 |
Correct |
17 ms |
9752 KB |
Output is correct |
26 |
Correct |
20 ms |
9736 KB |
Output is correct |
27 |
Correct |
521 ms |
158404 KB |
Output is correct |
28 |
Correct |
15 ms |
26196 KB |
Output is correct |
29 |
Correct |
33 ms |
13772 KB |
Output is correct |
30 |
Correct |
2 ms |
736 KB |
Output is correct |
31 |
Correct |
402 ms |
131312 KB |
Output is correct |
32 |
Correct |
486 ms |
158972 KB |
Output is correct |
33 |
Correct |
521 ms |
158428 KB |
Output is correct |
34 |
Correct |
441 ms |
152212 KB |
Output is correct |
35 |
Correct |
519 ms |
158868 KB |
Output is correct |
36 |
Correct |
493 ms |
158444 KB |
Output is correct |
37 |
Correct |
525 ms |
159004 KB |
Output is correct |
38 |
Correct |
375 ms |
130744 KB |
Output is correct |
39 |
Correct |
331 ms |
130736 KB |
Output is correct |