이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pt "--> "
#define Fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll ;
const int N = 3e3 + 7 , lg = 27 , len = 340 , Sq = 350 , oo = 2e9 , mod = 998244353 ;
int dx[9] = {0 , -1 , 0 , 1 , 0 , 1 , 1 , -1 , -1} , dy[9] = {0 , 0 , -1 , 0 , 1 , 1 , -1 , 1 , -1} ;
int n , m ;
ll ans ;
ll dp[N][N] , pd[N][N] ;
char c[N][N] ;
void solve() {
cin >> n >> m ;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
cin >> c[i][j] ;
for(int i = 1 ; i <= n ; i++)
for(int j = m ; j ; j--)
dp[i][j] = dp[i][j+1] + (c[i][j] == 'O') ;
for(int j = 1 ; j <= m ; j++)
for(int i = n ; i ; i--)
pd[i][j] = pd[i+1][j] + (c[i][j] == 'I') ;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= m ; j++)
if(c[i][j] == 'J')
ans += dp[i][j] * pd[i][j] ;
cout << ans << endl ;
}
int main(){
// Fast() ;
int T = 1 ;
while(T--)
solve() ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |