#include <iostream>
using namespace std;
const long long MAXN = 3010;
char arr[MAXN][MAXN];
long long dp[MAXN][MAXN];
long long dp2[MAXN][MAXN];
int main(){
long long n,m;
cin>>n>>m;
for(long long i=1;i<=n;i++){
for(long long j=1;j<=m;j++){
cin>>arr[i][j];
}
}
for(long long i=1;i<=n;i++){
for(long long j=m;j>=1;j--){
dp[i][j] = dp[i][j+1]+(arr[i][j] == 'O');
}
}
for(long long j=1;j<=m;j++){
for(long long i=n;i>=1;i--){
dp2[i][j] = dp2[i+1][j] + (arr[i][j] == 'I');
}
}
long long ans =0;
for(long long i=1;i<=n;i++){
for(long long j=1;j<=n;j++){
if(arr[i][j] == 'J'){
ans+= (dp2[i][j]*dp[i][j]);
}
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Incorrect |
3 ms |
1536 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Incorrect |
3 ms |
1536 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
7 |
Incorrect |
3 ms |
1536 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |