#include <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <system_error>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 200001
#define nl '\n'
#define pii1 pair<int, pair<int,int>> (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int>
#define int long long
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
const int INF=1e12;
/*
====================DEMONSTRATION======================
=========================END===========================
*/
int n,m;
int mat[3001][3001];
int ans;
int O[3002][3002];
int I[3002][3002];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
char x;
cin>>x;
if(x=='J')
{
mat[i][j]=1;
}
else if(x=='O')
{
mat[i][j]=2;
}
else
{
mat[i][j]=3;
}
}
}
for(int i=n;i>=1;--i)
{
for(int j=m;j>=1;--j)
{
O[i][j]+=O[i][j+1];
I[i][j]+=I[i+1][j];
if(mat[i][j]==2)
{
O[i][j]++;
}
if(mat[i][j]==3)
{
I[i][j]++;
}
}
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
if(I[i][j] && O[i][j] && mat[i][j]==1)
{
ans+=(I[i][j]*O[i][j]);
}
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
10 ms |
11120 KB |
Output is correct |
15 |
Correct |
2 ms |
5468 KB |
Output is correct |
16 |
Correct |
4 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
13 ms |
12636 KB |
Output is correct |
19 |
Correct |
8 ms |
12276 KB |
Output is correct |
20 |
Correct |
7 ms |
12216 KB |
Output is correct |
21 |
Correct |
14 ms |
12636 KB |
Output is correct |
22 |
Correct |
8 ms |
12304 KB |
Output is correct |
23 |
Correct |
8 ms |
12380 KB |
Output is correct |
24 |
Correct |
14 ms |
12636 KB |
Output is correct |
25 |
Correct |
8 ms |
12380 KB |
Output is correct |
26 |
Correct |
7 ms |
12380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
10 ms |
11120 KB |
Output is correct |
15 |
Correct |
2 ms |
5468 KB |
Output is correct |
16 |
Correct |
4 ms |
6748 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
13 ms |
12636 KB |
Output is correct |
19 |
Correct |
8 ms |
12276 KB |
Output is correct |
20 |
Correct |
7 ms |
12216 KB |
Output is correct |
21 |
Correct |
14 ms |
12636 KB |
Output is correct |
22 |
Correct |
8 ms |
12304 KB |
Output is correct |
23 |
Correct |
8 ms |
12380 KB |
Output is correct |
24 |
Correct |
14 ms |
12636 KB |
Output is correct |
25 |
Correct |
8 ms |
12380 KB |
Output is correct |
26 |
Correct |
7 ms |
12380 KB |
Output is correct |
27 |
Correct |
333 ms |
220084 KB |
Output is correct |
28 |
Correct |
12 ms |
29020 KB |
Output is correct |
29 |
Correct |
15 ms |
19548 KB |
Output is correct |
30 |
Correct |
1 ms |
1116 KB |
Output is correct |
31 |
Correct |
238 ms |
182592 KB |
Output is correct |
32 |
Correct |
195 ms |
220484 KB |
Output is correct |
33 |
Correct |
174 ms |
219988 KB |
Output is correct |
34 |
Correct |
287 ms |
211792 KB |
Output is correct |
35 |
Correct |
184 ms |
220480 KB |
Output is correct |
36 |
Correct |
176 ms |
219924 KB |
Output is correct |
37 |
Correct |
336 ms |
220752 KB |
Output is correct |
38 |
Correct |
144 ms |
182100 KB |
Output is correct |
39 |
Correct |
143 ms |
181888 KB |
Output is correct |