#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
char mat[3001][3001];
int oDesno[3001][3001];
int iDole[3001][3001];
int getO (int i, int j) {
if (j != 0) return oDesno[i][j-1];
else return 0;
}
int getI (int i, int j) {
if (i != 0) return iDole[i-1][j];
else return 0;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
for (int i = 0; i<n; i++) {
for (int j = 0; j<m; j++) {
cin>>mat[i][j];
oDesno[i][j] = (mat[i][j] == 'O') + getO(i,j);
iDole[i][j] = (mat[i][j] == 'I') + getI(i,j);
}
}
int res = 0;
for (int i = 0; i<n; i++) {
for (int j = 0; j<m; j++) {
if (mat[i][j] != 'J') continue;
res += (oDesno[i][m-1]-oDesno[i][j]) * (iDole[n-1][j]-oDesno[i][j]);
}
}
cout<<res<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |