#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
#define int ll
#define fore(a, b, c) for(int a=b; a<c; ++a)
#define vi vector<int>
#define pb push_back
#define ii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define dbg(x) cerr << #x << ": " << x << endl
#define raya cerr << "========================" << endl
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int H = 3003;
char g[H][H];
int Is[H][H];
int h, w;
signed main(){
cin >> h >> w;
fore(i, 0, h){
fore(j, 0, w){
cin >> g[i][j];
}
}
// cuantos Is hay debajo de J
fore(j, 0, w){
for(int i=h-1; i>=0; --i){
Is[i][j] = Is[i+1][j];
Is[i][j] += (g[i][j] == 'I');
}
}
int ans = 0;
fore(i, 0, h){
int sumaIs = 0;
fore(j, 0, w){
if(g[i][j] == 'J'){
sumaIs += Is[i][j];
}
if(g[i][j] == 'O'){
ans += sumaIs;
}
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4548 KB |
Output is correct |
7 |
Correct |
1 ms |
2908 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
1 ms |
4548 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4548 KB |
Output is correct |
7 |
Correct |
1 ms |
2908 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
1 ms |
4548 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
2908 KB |
Output is correct |
14 |
Correct |
7 ms |
15196 KB |
Output is correct |
15 |
Correct |
1 ms |
10844 KB |
Output is correct |
16 |
Correct |
5 ms |
7260 KB |
Output is correct |
17 |
Correct |
0 ms |
2488 KB |
Output is correct |
18 |
Correct |
9 ms |
15544 KB |
Output is correct |
19 |
Correct |
8 ms |
15452 KB |
Output is correct |
20 |
Correct |
7 ms |
15276 KB |
Output is correct |
21 |
Correct |
8 ms |
15540 KB |
Output is correct |
22 |
Correct |
8 ms |
15452 KB |
Output is correct |
23 |
Correct |
8 ms |
15404 KB |
Output is correct |
24 |
Correct |
9 ms |
15452 KB |
Output is correct |
25 |
Correct |
7 ms |
15448 KB |
Output is correct |
26 |
Correct |
8 ms |
15224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4548 KB |
Output is correct |
7 |
Correct |
1 ms |
2908 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
2908 KB |
Output is correct |
11 |
Correct |
1 ms |
4548 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
2908 KB |
Output is correct |
14 |
Correct |
7 ms |
15196 KB |
Output is correct |
15 |
Correct |
1 ms |
10844 KB |
Output is correct |
16 |
Correct |
5 ms |
7260 KB |
Output is correct |
17 |
Correct |
0 ms |
2488 KB |
Output is correct |
18 |
Correct |
9 ms |
15544 KB |
Output is correct |
19 |
Correct |
8 ms |
15452 KB |
Output is correct |
20 |
Correct |
7 ms |
15276 KB |
Output is correct |
21 |
Correct |
8 ms |
15540 KB |
Output is correct |
22 |
Correct |
8 ms |
15452 KB |
Output is correct |
23 |
Correct |
8 ms |
15404 KB |
Output is correct |
24 |
Correct |
9 ms |
15452 KB |
Output is correct |
25 |
Correct |
7 ms |
15448 KB |
Output is correct |
26 |
Correct |
8 ms |
15224 KB |
Output is correct |
27 |
Correct |
269 ms |
88112 KB |
Output is correct |
28 |
Correct |
6 ms |
62044 KB |
Output is correct |
29 |
Correct |
18 ms |
9052 KB |
Output is correct |
30 |
Correct |
1 ms |
2652 KB |
Output is correct |
31 |
Correct |
209 ms |
73500 KB |
Output is correct |
32 |
Correct |
264 ms |
88400 KB |
Output is correct |
33 |
Correct |
242 ms |
88400 KB |
Output is correct |
34 |
Correct |
211 ms |
84764 KB |
Output is correct |
35 |
Correct |
265 ms |
88344 KB |
Output is correct |
36 |
Correct |
254 ms |
88476 KB |
Output is correct |
37 |
Correct |
275 ms |
88404 KB |
Output is correct |
38 |
Correct |
212 ms |
73368 KB |
Output is correct |
39 |
Correct |
185 ms |
73120 KB |
Output is correct |