This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define task "TEST"
#define task2 "A"
#define pl pair<int, int>
#define pf push_front
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (int i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (int i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int Mod = 1e9+7;
const int maxn = 5e3;
const int Inf = 3e6;
ll n, h, w, res, row[maxn+1], col[maxn+1];
string str[maxn+1];
void Read()
{
cin >> h >> w;
FOR(i, 1, h, 1) cin >> str[i];
}
void Solve()
{
FORE(i, h, 1, -1) FORE(j, w-1, 0, -1) {
if (str[i][j] == 'I') col[j]++;
else if (str[i][j] == 'O') row[i]++;
else res += col[j] * row[i];
}
cout << res;
}
int main()
{
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
for (t=1; t--;)
{
Read(); Solve();
}
}
Compilation message (stderr)
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:39:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | freopen (task".inp", "r", stdin);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:40:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | 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... |