#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")
int n,m;
char dizi[3005][3005];
vector<pair<int,int> > v;
int dp[3005][3005];
void solve()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>dizi[i][j];
if(dizi[i][j]=='J')
v.push_back({i,j});
}
for(int i=1;i<=n;i++)
{
int o=0;
for(int j=m;j>=1;j--)
{
if(dizi[i][j]=='O')
o++;
else if(dizi[i][j]=='J')
dp[i][j]=o;
}
}
for(int i=1;i<=m;i++)
{
int o=0;
for(int j=n;j>=1;j--)
{
if(dizi[j][i]=='I')
o++;
else if(dizi[j][i]=='J')
dp[j][i]*=o;
}
}
int cvp=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cvp+=dp[i][j];
cout<<cvp;
}
signed main()
{
fast1
//freopen ("lca.gir","r",stdin);
//freopen ("lca.cik","w",stdout);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
976 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
972 KB |
Output is correct |
11 |
Correct |
2 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
976 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
972 KB |
Output is correct |
11 |
Correct |
2 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
9 ms |
5376 KB |
Output is correct |
15 |
Correct |
1 ms |
3148 KB |
Output is correct |
16 |
Correct |
6 ms |
3020 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
12 ms |
5688 KB |
Output is correct |
19 |
Correct |
6 ms |
4816 KB |
Output is correct |
20 |
Incorrect |
6 ms |
5064 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1100 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
1 ms |
976 KB |
Output is correct |
8 |
Correct |
1 ms |
1100 KB |
Output is correct |
9 |
Correct |
1 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
972 KB |
Output is correct |
11 |
Correct |
2 ms |
1100 KB |
Output is correct |
12 |
Correct |
1 ms |
972 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
9 ms |
5376 KB |
Output is correct |
15 |
Correct |
1 ms |
3148 KB |
Output is correct |
16 |
Correct |
6 ms |
3020 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
12 ms |
5688 KB |
Output is correct |
19 |
Correct |
6 ms |
4816 KB |
Output is correct |
20 |
Incorrect |
6 ms |
5064 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |