Submission #775852

# Submission time Handle Problem Language Result Execution time Memory
775852 2023-07-07T05:16:29 Z gun_gan Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
583 ms 75116 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 3e3 + 7;
int N, M;
vector<int> vert[MX], hori[MX];
vector<pair<int, int>> pos;

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);

      cin >> N >> M;
      for(int i = 0; i < N; i++) {
            for(int j = 0; j < M; j++) {
                  char c;
                  cin >> c;

                  if(c == 'J') {
                        pos.push_back({i, j});
                  } else if(c == 'O') {
                        hori[i].push_back(j);
                  } else {
                        vert[j].push_back(i);
                  }     
            }
      }

      ll ans = 0;
      for(auto [x, y] : pos) {
            auto p = lower_bound(hori[x].begin(), hori[x].end(), y) - hori[x].begin();
            auto q = lower_bound(vert[y].begin(), vert[y].end(), x) - vert[y].begin();

            ans += 1LL * (hori[x].size() - p) * (vert[y].size() - q);
      }

      cout << ans << '\n';
            
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 10 ms 1868 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 4 ms 1360 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 13 ms 2636 KB Output is correct
19 Correct 5 ms 2000 KB Output is correct
20 Correct 5 ms 2068 KB Output is correct
21 Correct 13 ms 2636 KB Output is correct
22 Correct 7 ms 2380 KB Output is correct
23 Correct 6 ms 2000 KB Output is correct
24 Correct 13 ms 2252 KB Output is correct
25 Correct 5 ms 2000 KB Output is correct
26 Correct 5 ms 2068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 456 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 10 ms 1868 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 4 ms 1360 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 13 ms 2636 KB Output is correct
19 Correct 5 ms 2000 KB Output is correct
20 Correct 5 ms 2068 KB Output is correct
21 Correct 13 ms 2636 KB Output is correct
22 Correct 7 ms 2380 KB Output is correct
23 Correct 6 ms 2000 KB Output is correct
24 Correct 13 ms 2252 KB Output is correct
25 Correct 5 ms 2000 KB Output is correct
26 Correct 5 ms 2068 KB Output is correct
27 Correct 499 ms 62240 KB Output is correct
28 Correct 2 ms 728 KB Output is correct
29 Correct 15 ms 5304 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 368 ms 44356 KB Output is correct
32 Correct 203 ms 60856 KB Output is correct
33 Correct 231 ms 64712 KB Output is correct
34 Correct 431 ms 61396 KB Output is correct
35 Correct 312 ms 65468 KB Output is correct
36 Correct 235 ms 64684 KB Output is correct
37 Correct 583 ms 75116 KB Output is correct
38 Correct 127 ms 42020 KB Output is correct
39 Correct 149 ms 49492 KB Output is correct