#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
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 |
1 |
Correct |
1 ms |
592 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
760 KB |
Output is correct |
4 |
Correct |
1 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
632 KB |
Output is correct |
6 |
Correct |
1 ms |
772 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
848 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
592 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
760 KB |
Output is correct |
4 |
Correct |
1 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
632 KB |
Output is correct |
6 |
Correct |
1 ms |
772 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
848 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
848 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
848 KB |
Output is correct |
17 |
Correct |
1 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
1104 KB |
Output is correct |
19 |
Correct |
2 ms |
1104 KB |
Output is correct |
20 |
Correct |
2 ms |
1104 KB |
Output is correct |
21 |
Correct |
3 ms |
1104 KB |
Output is correct |
22 |
Correct |
2 ms |
1272 KB |
Output is correct |
23 |
Correct |
2 ms |
984 KB |
Output is correct |
24 |
Correct |
3 ms |
1104 KB |
Output is correct |
25 |
Correct |
2 ms |
1104 KB |
Output is correct |
26 |
Correct |
2 ms |
1104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
592 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
1 ms |
760 KB |
Output is correct |
4 |
Correct |
1 ms |
592 KB |
Output is correct |
5 |
Correct |
1 ms |
632 KB |
Output is correct |
6 |
Correct |
1 ms |
772 KB |
Output is correct |
7 |
Correct |
1 ms |
592 KB |
Output is correct |
8 |
Correct |
1 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
848 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
592 KB |
Output is correct |
13 |
Correct |
1 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
848 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
848 KB |
Output is correct |
17 |
Correct |
1 ms |
592 KB |
Output is correct |
18 |
Correct |
3 ms |
1104 KB |
Output is correct |
19 |
Correct |
2 ms |
1104 KB |
Output is correct |
20 |
Correct |
2 ms |
1104 KB |
Output is correct |
21 |
Correct |
3 ms |
1104 KB |
Output is correct |
22 |
Correct |
2 ms |
1272 KB |
Output is correct |
23 |
Correct |
2 ms |
984 KB |
Output is correct |
24 |
Correct |
3 ms |
1104 KB |
Output is correct |
25 |
Correct |
2 ms |
1104 KB |
Output is correct |
26 |
Correct |
2 ms |
1104 KB |
Output is correct |
27 |
Correct |
84 ms |
17900 KB |
Output is correct |
28 |
Correct |
1 ms |
592 KB |
Output is correct |
29 |
Correct |
3 ms |
1872 KB |
Output is correct |
30 |
Correct |
1 ms |
592 KB |
Output is correct |
31 |
Correct |
62 ms |
13384 KB |
Output is correct |
32 |
Correct |
52 ms |
18816 KB |
Output is correct |
33 |
Correct |
41 ms |
19016 KB |
Output is correct |
34 |
Correct |
70 ms |
15460 KB |
Output is correct |
35 |
Correct |
46 ms |
18968 KB |
Output is correct |
36 |
Correct |
39 ms |
18924 KB |
Output is correct |
37 |
Correct |
78 ms |
19016 KB |
Output is correct |
38 |
Correct |
39 ms |
13128 KB |
Output is correct |
39 |
Correct |
29 ms |
13384 KB |
Output is correct |