이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///
/// breakdown breakdown
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
typedef long long ll;
using namespace std;
const int N = 3010;
char g[N][N];
ll O[N][N];
ll I[N][N];
int n, m;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
Loop(i,0,n)
{
Loop(j,0,m)
{
cin >> g[i][j];
if(g[i][j] == 'O') O[i][j]++;
if(g[i][j] == 'I') I[i][j]++;
}
}
Loop(i,0,n) LoopR(j,0,m-1)
O[i][j] += O[i][j+1];
LoopR(i,0,n-1) Loop(j,0,m)
I[i][j] += I[i+1][j];
ll ans = 0;
Loop(i,0,n) Loop(j,0,m)
if(g[i][j] == 'J')
ans += O[i][j]*I[i][j];
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |