Submission #394256

# Submission time Handle Problem Language Result Execution time Memory
394256 2021-04-26T09:07:42 Z retsiger Examination (JOI19_examination) C++14
100 / 100
527 ms 22352 KB
#include<bits/stdc++.h>
#define bug(x) cerr<<#x<<" = "<<x<<'\n'

using namespace std;

const int maxn = 1e5;

int N, Q, S[maxn], T[maxn], x, A[maxn], B[maxn], C[maxn], Ans[maxn];
vector <int> vs, vt[maxn + 1], ft[maxn + 1];
array<int, 2> D[maxn], E[maxn];

int main() {
//  freopen("cc.inp", "r", stdin);
//  freopen("cc.out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> N >> Q;
  for (int i = 0; i < N; ++i) {
    cin >> S[i] >> T[i];
    S[i] = -S[i]; T[i] = -T[i];
    vs.push_back(S[i]);
    D[i] = {S[i] + T[i], i};
  }
  sort(vs.begin(), vs.end());
  vs.resize(x = unique(vs.begin(), vs.end()) - vs.begin());
  for (int i = 0; i < N; ++i) {
    S[i] = lower_bound(vs.begin(), vs.end(), S[i]) - vs.begin();
    for (int j = S[i] + 1; j <= x; j += j & -j)
      vt[j].push_back(T[i]);
  }
  for (int i = 1; i <= x; ++i) {
    sort(vt[i].begin(), vt[i].end());
    vt[i].resize(unique(vt[i].begin(), vt[i].end()) - vt[i].begin());
    ft[i].resize(vt[i].size() + 1);
  }
  sort(D, D + N);
  for (int i = 0; i < Q; ++i) {
    cin >> A[i] >> B[i] >> C[i];
    A[i] = -A[i];
    B[i] = -B[i];
    C[i] = -C[i];
    E[i] = {C[i], i};
  }
  sort(E, E + Q);
  for (int i1 = 0, i2 = 0; i1 < Q; ++i1) {
    while (i2 < N && D[i2][0] <= E[i1][0]) {
      for (int i = S[D[i2][1]] + 1; i <= x; i += i & -i)
        for (int j = lower_bound(vt[i].begin(), vt[i].end(), T[D[i2][1]]) - vt[i].begin() + 1; j <= vt[i].size(); j += j & -j)
          ft[i][j]++;
      ++i2;
    }
    for (int i = upper_bound(vs.begin(), vs.end(), A[E[i1][1]]) - vs.begin(); i; i -= i & -i) {
      for (int j = upper_bound(vt[i].begin(), vt[i].end(), B[E[i1][1]]) - vt[i].begin(); j; j -= j & -j)
        Ans[E[i1][1]] += ft[i][j];
    }
  }
  for (int i = 0; i < Q; ++i)
    cout << Ans[i] << '\n';
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:47:98: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j = lower_bound(vt[i].begin(), vt[i].end(), T[D[i2][1]]) - vt[i].begin() + 1; j <= vt[i].size(); j += j & -j)
      |                                                                                                ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 10 ms 5548 KB Output is correct
8 Correct 10 ms 5456 KB Output is correct
9 Correct 11 ms 5552 KB Output is correct
10 Correct 10 ms 5452 KB Output is correct
11 Correct 7 ms 5292 KB Output is correct
12 Correct 6 ms 5196 KB Output is correct
13 Correct 10 ms 5452 KB Output is correct
14 Correct 10 ms 5532 KB Output is correct
15 Correct 10 ms 5512 KB Output is correct
16 Correct 6 ms 5256 KB Output is correct
17 Correct 8 ms 5452 KB Output is correct
18 Correct 5 ms 5200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 413 ms 19572 KB Output is correct
2 Correct 411 ms 19612 KB Output is correct
3 Correct 412 ms 19536 KB Output is correct
4 Correct 218 ms 17328 KB Output is correct
5 Correct 142 ms 11772 KB Output is correct
6 Correct 93 ms 11320 KB Output is correct
7 Correct 383 ms 19564 KB Output is correct
8 Correct 379 ms 19592 KB Output is correct
9 Correct 355 ms 19512 KB Output is correct
10 Correct 99 ms 10312 KB Output is correct
11 Correct 177 ms 16836 KB Output is correct
12 Correct 66 ms 10132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 413 ms 19572 KB Output is correct
2 Correct 411 ms 19612 KB Output is correct
3 Correct 412 ms 19536 KB Output is correct
4 Correct 218 ms 17328 KB Output is correct
5 Correct 142 ms 11772 KB Output is correct
6 Correct 93 ms 11320 KB Output is correct
7 Correct 383 ms 19564 KB Output is correct
8 Correct 379 ms 19592 KB Output is correct
9 Correct 355 ms 19512 KB Output is correct
10 Correct 99 ms 10312 KB Output is correct
11 Correct 177 ms 16836 KB Output is correct
12 Correct 66 ms 10132 KB Output is correct
13 Correct 447 ms 19524 KB Output is correct
14 Correct 446 ms 19536 KB Output is correct
15 Correct 412 ms 19524 KB Output is correct
16 Correct 250 ms 17244 KB Output is correct
17 Correct 157 ms 11864 KB Output is correct
18 Correct 102 ms 11328 KB Output is correct
19 Correct 458 ms 19496 KB Output is correct
20 Correct 454 ms 19476 KB Output is correct
21 Correct 424 ms 19652 KB Output is correct
22 Correct 97 ms 10500 KB Output is correct
23 Correct 183 ms 17000 KB Output is correct
24 Correct 64 ms 10180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 10 ms 5548 KB Output is correct
8 Correct 10 ms 5456 KB Output is correct
9 Correct 11 ms 5552 KB Output is correct
10 Correct 10 ms 5452 KB Output is correct
11 Correct 7 ms 5292 KB Output is correct
12 Correct 6 ms 5196 KB Output is correct
13 Correct 10 ms 5452 KB Output is correct
14 Correct 10 ms 5532 KB Output is correct
15 Correct 10 ms 5512 KB Output is correct
16 Correct 6 ms 5256 KB Output is correct
17 Correct 8 ms 5452 KB Output is correct
18 Correct 5 ms 5200 KB Output is correct
19 Correct 413 ms 19572 KB Output is correct
20 Correct 411 ms 19612 KB Output is correct
21 Correct 412 ms 19536 KB Output is correct
22 Correct 218 ms 17328 KB Output is correct
23 Correct 142 ms 11772 KB Output is correct
24 Correct 93 ms 11320 KB Output is correct
25 Correct 383 ms 19564 KB Output is correct
26 Correct 379 ms 19592 KB Output is correct
27 Correct 355 ms 19512 KB Output is correct
28 Correct 99 ms 10312 KB Output is correct
29 Correct 177 ms 16836 KB Output is correct
30 Correct 66 ms 10132 KB Output is correct
31 Correct 447 ms 19524 KB Output is correct
32 Correct 446 ms 19536 KB Output is correct
33 Correct 412 ms 19524 KB Output is correct
34 Correct 250 ms 17244 KB Output is correct
35 Correct 157 ms 11864 KB Output is correct
36 Correct 102 ms 11328 KB Output is correct
37 Correct 458 ms 19496 KB Output is correct
38 Correct 454 ms 19476 KB Output is correct
39 Correct 424 ms 19652 KB Output is correct
40 Correct 97 ms 10500 KB Output is correct
41 Correct 183 ms 17000 KB Output is correct
42 Correct 64 ms 10180 KB Output is correct
43 Correct 527 ms 21976 KB Output is correct
44 Correct 509 ms 22184 KB Output is correct
45 Correct 499 ms 22128 KB Output is correct
46 Correct 274 ms 19780 KB Output is correct
47 Correct 164 ms 12556 KB Output is correct
48 Correct 105 ms 11588 KB Output is correct
49 Correct 458 ms 22352 KB Output is correct
50 Correct 478 ms 22084 KB Output is correct
51 Correct 420 ms 22184 KB Output is correct
52 Correct 114 ms 11208 KB Output is correct
53 Correct 219 ms 19464 KB Output is correct