#include <bits/stdc++.h>
#define TASK "askdjaskdj"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///
int n,m;
char a[3005][3005];
void inp()
{
cin >> n >> m;
FOR(i, 1, n)
{
FOR(j, 1, m) cin >> a[i][j];
}
}
ll ans = 0;
ll f[3005][3005], g[3005][3005];
void solve()
{
FOR(i, 1, n)
{
int cnt = 0;
FORD(j, m, 1)
{
if (a[i][j]=='J') f[i][j] = cnt;
else if (a[i][j]=='O') cnt++;
}
}
FOR(j, 1, m)
{
int cnt = 0;
FORD(i, n, 1)
{
if (a[i][j]=='J') g[i][j] = cnt;
else if (a[i][j]=='I') cnt++;
}
}
FOR(i, 1, n) FOR(j, 1, m)
{
ans+= f[i][j]*g[i][j];
}
cout << ans;
}
signed main()
{
///--------------------------///
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
if (fopen(TASK".INP","r")!=NULL)
{
freopen(TASK".INP","r",stdin);
freopen(TASK".OUT","w",stdout);
}
///--------------------------///
int NTEST = 1;
//cin >> NTEST;
while (NTEST--)
{
inp();
solve();
}
return 0;
}
///------------------------------------------///
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
66 | freopen(TASK".INP","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | freopen(TASK".OUT","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |