#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
//Dijkstra->set
//set.find_by_order(x) x-position value
//set.order_of_key(x) number of strictly less elements don't need *set.??
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
int main ()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<char>> c(n+1, vector<char>(m+1));
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++) cin >> c[i][j];
}
vector<vector<int>> po(n+1, vector<int>(m+1, 0));
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++) po[i][j] = po[i][j-1]+(c[i][j] == 'O');
}
vector<vector<int>> pi(n+1, vector<int>(m+1, 0));
for (int i = 1; i <= m; i++){
for (int j = 1; j <= n; j++){
pi[j][i] = pi[j-1][i]+(c[j][i] == 'I');
}
}
ll ans = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (c[i][j] == 'J'){
ans += (po[i][m]-po[i][j])*(pi[n][j]-pi[i][j]);
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
2248 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1620 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
6 ms |
2772 KB |
Output is correct |
19 |
Correct |
5 ms |
2644 KB |
Output is correct |
20 |
Correct |
5 ms |
2772 KB |
Output is correct |
21 |
Correct |
6 ms |
2760 KB |
Output is correct |
22 |
Correct |
5 ms |
2736 KB |
Output is correct |
23 |
Correct |
5 ms |
2772 KB |
Output is correct |
24 |
Correct |
6 ms |
2772 KB |
Output is correct |
25 |
Correct |
5 ms |
2636 KB |
Output is correct |
26 |
Correct |
5 ms |
2772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
2248 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1620 KB |
Output is correct |
17 |
Correct |
1 ms |
320 KB |
Output is correct |
18 |
Correct |
6 ms |
2772 KB |
Output is correct |
19 |
Correct |
5 ms |
2644 KB |
Output is correct |
20 |
Correct |
5 ms |
2772 KB |
Output is correct |
21 |
Correct |
6 ms |
2760 KB |
Output is correct |
22 |
Correct |
5 ms |
2736 KB |
Output is correct |
23 |
Correct |
5 ms |
2772 KB |
Output is correct |
24 |
Correct |
6 ms |
2772 KB |
Output is correct |
25 |
Correct |
5 ms |
2636 KB |
Output is correct |
26 |
Correct |
5 ms |
2772 KB |
Output is correct |
27 |
Correct |
259 ms |
83064 KB |
Output is correct |
28 |
Correct |
1 ms |
852 KB |
Output is correct |
29 |
Correct |
12 ms |
6712 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
183 ms |
61764 KB |
Output is correct |
32 |
Correct |
269 ms |
86900 KB |
Output is correct |
33 |
Correct |
249 ms |
87136 KB |
Output is correct |
34 |
Correct |
210 ms |
71504 KB |
Output is correct |
35 |
Correct |
257 ms |
86988 KB |
Output is correct |
36 |
Correct |
289 ms |
87140 KB |
Output is correct |
37 |
Correct |
284 ms |
87400 KB |
Output is correct |
38 |
Correct |
164 ms |
61292 KB |
Output is correct |
39 |
Correct |
160 ms |
61512 KB |
Output is correct |