#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define SORT(x) sort((x).begin(), (x).end())
#define CMPSORT(x, cp) sort((x).begin(), (x).end(), cp)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define getchar_unlocked _getchar_nolock
#define INF ((long long)1e18)
#define MOD 1000000007
#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';
int main(){
FAST
ll h, w;
char grid[3010][3010];
cin >> h >> w;
FOR(i, 1, h){
FOR(j, 1, w){
cin >> grid[i][j];
}
}
ll power[3010], total=0;
MEM(power, 0);
FOR(i, 1, h){
FOR(j, 1, w){
if (grid[i][j]=='I') total+=power[j];
}
ll ocnt=0;
ROF(j, w, 1){
if (grid[i][j]=='O') ocnt++;
if (grid[i][j]=='J') power[j]+=ocnt;
}
}
cout << total;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
10 ms |
1784 KB |
Output is correct |
15 |
Correct |
5 ms |
1656 KB |
Output is correct |
16 |
Correct |
7 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
380 KB |
Output is correct |
18 |
Correct |
12 ms |
1784 KB |
Output is correct |
19 |
Correct |
9 ms |
1784 KB |
Output is correct |
20 |
Correct |
9 ms |
1784 KB |
Output is correct |
21 |
Correct |
12 ms |
1784 KB |
Output is correct |
22 |
Correct |
9 ms |
1784 KB |
Output is correct |
23 |
Correct |
9 ms |
1784 KB |
Output is correct |
24 |
Correct |
13 ms |
1784 KB |
Output is correct |
25 |
Correct |
9 ms |
2040 KB |
Output is correct |
26 |
Correct |
9 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
632 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
632 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
5 ms |
632 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
10 ms |
1784 KB |
Output is correct |
15 |
Correct |
5 ms |
1656 KB |
Output is correct |
16 |
Correct |
7 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
380 KB |
Output is correct |
18 |
Correct |
12 ms |
1784 KB |
Output is correct |
19 |
Correct |
9 ms |
1784 KB |
Output is correct |
20 |
Correct |
9 ms |
1784 KB |
Output is correct |
21 |
Correct |
12 ms |
1784 KB |
Output is correct |
22 |
Correct |
9 ms |
1784 KB |
Output is correct |
23 |
Correct |
9 ms |
1784 KB |
Output is correct |
24 |
Correct |
13 ms |
1784 KB |
Output is correct |
25 |
Correct |
9 ms |
2040 KB |
Output is correct |
26 |
Correct |
9 ms |
1784 KB |
Output is correct |
27 |
Correct |
241 ms |
9208 KB |
Output is correct |
28 |
Correct |
8 ms |
7160 KB |
Output is correct |
29 |
Correct |
15 ms |
1144 KB |
Output is correct |
30 |
Correct |
5 ms |
376 KB |
Output is correct |
31 |
Correct |
171 ms |
7800 KB |
Output is correct |
32 |
Correct |
150 ms |
9208 KB |
Output is correct |
33 |
Correct |
134 ms |
9324 KB |
Output is correct |
34 |
Correct |
189 ms |
8952 KB |
Output is correct |
35 |
Correct |
160 ms |
9348 KB |
Output is correct |
36 |
Correct |
140 ms |
9208 KB |
Output is correct |
37 |
Correct |
247 ms |
9136 KB |
Output is correct |
38 |
Correct |
110 ms |
7776 KB |
Output is correct |
39 |
Correct |
105 ms |
7672 KB |
Output is correct |