#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}
void solve(){
int n;
cin >> n;
int m;
cin >> m;
string s[n];
for(int i = 0; i < n; i++)cin >> s[i];
ll cnt[n][m] , cnt1[n][m];
for(int i = 0; i < n; i++){
cnt[i][0] = 0;
for(int j = 1; j < m; j++){
cnt[i][j] = cnt[i][j-1];
if(s[i][j] == 'O')cnt[i][j]++;
}
}
for(int j = 0; j < m; j++){
cnt1[0][j] = 0;
for(int i = 1; i < n; i++){
cnt1[i][j] = cnt1[i-1][j];
if(s[i][j] == 'I')cnt1[i][j]++;
}
}
ll ans = 0;
for(ll i = 0; i < n; i++){
for(ll j = 0; j < m; j++){
if(s[i][j] == 'J'){
ans += (cnt[i][m-1] - cnt[i][j]) * (cnt1[n-1][j] - cnt1[i][j]);
}
}
}
cout << ans << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//int t;cin >> t;while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
5 ms |
3788 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
2508 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
4680 KB |
Output is correct |
19 |
Correct |
4 ms |
4556 KB |
Output is correct |
20 |
Correct |
5 ms |
4556 KB |
Output is correct |
21 |
Correct |
6 ms |
4684 KB |
Output is correct |
22 |
Correct |
4 ms |
4556 KB |
Output is correct |
23 |
Correct |
4 ms |
4556 KB |
Output is correct |
24 |
Correct |
6 ms |
4676 KB |
Output is correct |
25 |
Correct |
4 ms |
4556 KB |
Output is correct |
26 |
Correct |
4 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
5 ms |
3788 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
2508 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
7 ms |
4680 KB |
Output is correct |
19 |
Correct |
4 ms |
4556 KB |
Output is correct |
20 |
Correct |
5 ms |
4556 KB |
Output is correct |
21 |
Correct |
6 ms |
4684 KB |
Output is correct |
22 |
Correct |
4 ms |
4556 KB |
Output is correct |
23 |
Correct |
4 ms |
4556 KB |
Output is correct |
24 |
Correct |
6 ms |
4676 KB |
Output is correct |
25 |
Correct |
4 ms |
4556 KB |
Output is correct |
26 |
Correct |
4 ms |
4556 KB |
Output is correct |
27 |
Correct |
269 ms |
150868 KB |
Output is correct |
28 |
Correct |
2 ms |
716 KB |
Output is correct |
29 |
Correct |
11 ms |
11724 KB |
Output is correct |
30 |
Correct |
1 ms |
708 KB |
Output is correct |
31 |
Correct |
194 ms |
110968 KB |
Output is correct |
32 |
Correct |
259 ms |
158700 KB |
Output is correct |
33 |
Correct |
241 ms |
159172 KB |
Output is correct |
34 |
Correct |
238 ms |
128784 KB |
Output is correct |
35 |
Correct |
267 ms |
158680 KB |
Output is correct |
36 |
Correct |
236 ms |
159280 KB |
Output is correct |
37 |
Correct |
314 ms |
159808 KB |
Output is correct |
38 |
Correct |
156 ms |
110020 KB |
Output is correct |
39 |
Correct |
142 ms |
110532 KB |
Output is correct |