#include<bits/stdc++.h>
using namespace std;
int main(){
int h, w;
cin >> h >> w;
char grid [h + 1][w + 1];
for(int i = 1; i <= h; i++){
for(int j = 0; j <= w; j++) cin >> grid[i][j];
}
pair<int, pair<int, int> > dp[h + 2][w + 2];
for(int i = 0; i < h + 2; i++) dp[i][w + 1] = make_pair(0, make_pair(0, 0));
for(int i = 0; i < w + 2; i++) dp[0][i] = make_pair(0, make_pair(0, 0));
for(int i = 1; i <= h; i++){
for(int j = w; j > 0; j++){
int noOfO = dp[i][w - 1].second.second;
if(grid[i][j] == 'O') noOfO += 1;
int noOfJo = dp[i-1][w].second.first;
if(grid[i][j] == 'J') noOfJo += noOfO;
int pow = dp[i-1][w].first;
if(grid[i][j] == 'I') pow += noOfJo;
}
}
int ans = 0;
for(int i = 1; i <= w; i++) ans += dp[h][i].first;
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |