#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
for(const auto &a:p)
os << a << " ";
os << "\n";
return os;
}
int ocnt[3010][3010], icnt[3010][3010];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int h, w;
cin>>h>>w;
vector<string> grid(h);
rep(i,0,h){
cin>>grid[i];
for(int j=w-1;j>=0;--j) ocnt[i][j]=ocnt[i][j+1]+(grid[i][j]=='O');
}
rep(j,0,w){
for(int i=h-1;i>=0;--i) icnt[i][j]=icnt[i+1][j]+(grid[i][j]=='I');
}
ll ans=0;
rep(i,0,h){
rep(j,0,w) if(grid[i][j]=='J') ans+=ocnt[i][j+1]*icnt[i+1][j];
// rep(j,0,w) cout<<icnt[j]<<" ";
// cout<<NL;
}
cout<<ans<<NL;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1240 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1104 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1240 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1104 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
6 ms |
6228 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
3 ms |
3644 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
6740 KB |
Output is correct |
19 |
Correct |
5 ms |
6632 KB |
Output is correct |
20 |
Correct |
5 ms |
6616 KB |
Output is correct |
21 |
Correct |
6 ms |
6740 KB |
Output is correct |
22 |
Correct |
6 ms |
6612 KB |
Output is correct |
23 |
Correct |
5 ms |
6612 KB |
Output is correct |
24 |
Correct |
6 ms |
6740 KB |
Output is correct |
25 |
Correct |
5 ms |
6744 KB |
Output is correct |
26 |
Correct |
5 ms |
6616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1240 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1104 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
6 ms |
6228 KB |
Output is correct |
15 |
Correct |
2 ms |
3668 KB |
Output is correct |
16 |
Correct |
3 ms |
3644 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
6740 KB |
Output is correct |
19 |
Correct |
5 ms |
6632 KB |
Output is correct |
20 |
Correct |
5 ms |
6616 KB |
Output is correct |
21 |
Correct |
6 ms |
6740 KB |
Output is correct |
22 |
Correct |
6 ms |
6612 KB |
Output is correct |
23 |
Correct |
5 ms |
6612 KB |
Output is correct |
24 |
Correct |
6 ms |
6740 KB |
Output is correct |
25 |
Correct |
5 ms |
6744 KB |
Output is correct |
26 |
Correct |
5 ms |
6616 KB |
Output is correct |
27 |
Correct |
213 ms |
81432 KB |
Output is correct |
28 |
Correct |
10 ms |
19288 KB |
Output is correct |
29 |
Correct |
9 ms |
7708 KB |
Output is correct |
30 |
Correct |
1 ms |
528 KB |
Output is correct |
31 |
Correct |
158 ms |
67196 KB |
Output is correct |
32 |
Correct |
199 ms |
81932 KB |
Output is correct |
33 |
Correct |
199 ms |
81868 KB |
Output is correct |
34 |
Correct |
178 ms |
77684 KB |
Output is correct |
35 |
Correct |
199 ms |
81880 KB |
Output is correct |
36 |
Correct |
198 ms |
81672 KB |
Output is correct |
37 |
Correct |
222 ms |
82080 KB |
Output is correct |
38 |
Correct |
135 ms |
67172 KB |
Output is correct |
39 |
Correct |
145 ms |
66816 KB |
Output is correct |