이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 3010;
int n, m;
ll row[maxn][maxn], col[maxn][maxn];
char c[maxn][maxn];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
cin >> c[i][j];
if (c[i][j] == 'O')
row[i][j] ++;
else if (c[i][j] == 'I')
col[i][j] ++;
}
for (int i = 1; i <= n; i ++)
for (int j = m; j > 0; j --)
row[i][j] = row[i][j + 1] + row[i][j];
for (int j = 1; j <= m; j ++)
for (int i = n; i > 0; i --)
col[i][j] = col[i + 1][j] + col[i][j];
ll ans = 0;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= m; j ++)
{
if (c[i][j] == 'J')
{
ans = ans + row[i][j] * col[i][j];
///cout << i << " " << j << " " << row[i][j] * col[i][j] << endl;
}
}
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
/**
3 4
JOIJ
JIOO
IIII
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |