#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int N=3010;
int m,n,ret;
int r[N][N],d[N][N];
char a[N][N];
main(){
#define task "Bitaro"
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
fasty;
cin>>m>>n;
forinc(i,1,m) forinc(j,1,n) cin>>a[i][j];
forinc(i,1,m) fordec(j,n,1) r[i][j]=r[i][j+1] + (a[i][j]=='O');
fordec(i,m,1) forinc(j,1,n) d[i][j]=d[i+1][j] + (a[i][j]=='I');
forinc(i,1,m) forinc(j,1,n) if(a[i][j]=='J') ret+=r[i][j] * d[i][j];
cout<<ret;
}
Compilation message
joi2019_ho_t1.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1664 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1664 KB |
Output is correct |
9 |
Correct |
6 ms |
1664 KB |
Output is correct |
10 |
Correct |
5 ms |
1536 KB |
Output is correct |
11 |
Correct |
6 ms |
1664 KB |
Output is correct |
12 |
Correct |
7 ms |
1536 KB |
Output is correct |
13 |
Correct |
7 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1664 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1664 KB |
Output is correct |
9 |
Correct |
6 ms |
1664 KB |
Output is correct |
10 |
Correct |
5 ms |
1536 KB |
Output is correct |
11 |
Correct |
6 ms |
1664 KB |
Output is correct |
12 |
Correct |
7 ms |
1536 KB |
Output is correct |
13 |
Correct |
7 ms |
1536 KB |
Output is correct |
14 |
Correct |
14 ms |
9088 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5376 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
10112 KB |
Output is correct |
19 |
Correct |
13 ms |
9856 KB |
Output is correct |
20 |
Correct |
14 ms |
9856 KB |
Output is correct |
21 |
Correct |
15 ms |
10112 KB |
Output is correct |
22 |
Correct |
14 ms |
9856 KB |
Output is correct |
23 |
Correct |
18 ms |
9856 KB |
Output is correct |
24 |
Correct |
14 ms |
9984 KB |
Output is correct |
25 |
Correct |
20 ms |
9856 KB |
Output is correct |
26 |
Correct |
13 ms |
9856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
5 ms |
1664 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
1536 KB |
Output is correct |
8 |
Correct |
5 ms |
1664 KB |
Output is correct |
9 |
Correct |
6 ms |
1664 KB |
Output is correct |
10 |
Correct |
5 ms |
1536 KB |
Output is correct |
11 |
Correct |
6 ms |
1664 KB |
Output is correct |
12 |
Correct |
7 ms |
1536 KB |
Output is correct |
13 |
Correct |
7 ms |
1536 KB |
Output is correct |
14 |
Correct |
14 ms |
9088 KB |
Output is correct |
15 |
Correct |
7 ms |
5120 KB |
Output is correct |
16 |
Correct |
10 ms |
5376 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
10112 KB |
Output is correct |
19 |
Correct |
13 ms |
9856 KB |
Output is correct |
20 |
Correct |
14 ms |
9856 KB |
Output is correct |
21 |
Correct |
15 ms |
10112 KB |
Output is correct |
22 |
Correct |
14 ms |
9856 KB |
Output is correct |
23 |
Correct |
18 ms |
9856 KB |
Output is correct |
24 |
Correct |
14 ms |
9984 KB |
Output is correct |
25 |
Correct |
20 ms |
9856 KB |
Output is correct |
26 |
Correct |
13 ms |
9856 KB |
Output is correct |
27 |
Correct |
269 ms |
158948 KB |
Output is correct |
28 |
Correct |
21 ms |
26496 KB |
Output is correct |
29 |
Correct |
22 ms |
13952 KB |
Output is correct |
30 |
Correct |
6 ms |
896 KB |
Output is correct |
31 |
Correct |
190 ms |
131704 KB |
Output is correct |
32 |
Correct |
231 ms |
159336 KB |
Output is correct |
33 |
Correct |
253 ms |
158944 KB |
Output is correct |
34 |
Correct |
229 ms |
152704 KB |
Output is correct |
35 |
Correct |
239 ms |
159292 KB |
Output is correct |
36 |
Correct |
249 ms |
158804 KB |
Output is correct |
37 |
Correct |
269 ms |
159352 KB |
Output is correct |
38 |
Correct |
176 ms |
131064 KB |
Output is correct |
39 |
Correct |
171 ms |
131288 KB |
Output is correct |