#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)
int main() {
int H, W;
cin >> H;
cin >> W;
vvi jewel(H, vi(W));
vvi orb(H, vi(W));
vvi ingot(H, vi(W));
rep(h,0,H) {
string line;
cin >> line;
rep(w,0,W) {
if(line[w] == 'J')
jewel[h][w] = 1;
else if(line[w] == 'O')
orb[h][w] = 1;
else
ingot[h][w] = 1;
}
}
for(int h = H-2; h >= 0; h--)
rep(w,0,W)
ingot[h][w] += ingot[h+1][w];
for(int w = W-2; w >= 0; w--)
rep(h,0,H)
orb[h][w] += orb[h][w+1];
long sum = 0;
rep(h,0,H) {
rep(w,0,W) {
sum += ((long)orb[h][w])*((long)ingot[h][w])*((long)jewel[h][w]);
}
}
cout << sum << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
504 KB |
Output is correct |
14 |
Correct |
19 ms |
2680 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
1912 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
24 ms |
3320 KB |
Output is correct |
19 |
Correct |
21 ms |
3192 KB |
Output is correct |
20 |
Correct |
22 ms |
3192 KB |
Output is correct |
21 |
Correct |
24 ms |
3576 KB |
Output is correct |
22 |
Correct |
21 ms |
3468 KB |
Output is correct |
23 |
Correct |
21 ms |
3448 KB |
Output is correct |
24 |
Correct |
24 ms |
3576 KB |
Output is correct |
25 |
Correct |
21 ms |
3448 KB |
Output is correct |
26 |
Correct |
23 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
504 KB |
Output is correct |
14 |
Correct |
19 ms |
2680 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
1912 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
24 ms |
3320 KB |
Output is correct |
19 |
Correct |
21 ms |
3192 KB |
Output is correct |
20 |
Correct |
22 ms |
3192 KB |
Output is correct |
21 |
Correct |
24 ms |
3576 KB |
Output is correct |
22 |
Correct |
21 ms |
3468 KB |
Output is correct |
23 |
Correct |
21 ms |
3448 KB |
Output is correct |
24 |
Correct |
24 ms |
3576 KB |
Output is correct |
25 |
Correct |
21 ms |
3448 KB |
Output is correct |
26 |
Correct |
23 ms |
3576 KB |
Output is correct |
27 |
Correct |
838 ms |
108932 KB |
Output is correct |
28 |
Correct |
5 ms |
1016 KB |
Output is correct |
29 |
Correct |
52 ms |
8568 KB |
Output is correct |
30 |
Correct |
4 ms |
632 KB |
Output is correct |
31 |
Correct |
679 ms |
80120 KB |
Output is correct |
32 |
Correct |
831 ms |
114616 KB |
Output is correct |
33 |
Correct |
760 ms |
115080 KB |
Output is correct |
34 |
Correct |
661 ms |
93040 KB |
Output is correct |
35 |
Correct |
779 ms |
114680 KB |
Output is correct |
36 |
Correct |
755 ms |
114752 KB |
Output is correct |
37 |
Correct |
837 ms |
115352 KB |
Output is correct |
38 |
Correct |
522 ms |
79572 KB |
Output is correct |
39 |
Correct |
521 ms |
79800 KB |
Output is correct |