답안 #703670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703670 2023-02-28T05:39:49 Z LittleCube Examination (JOI19_examination) C++14
100 / 100
2163 ms 202440 KB
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

int N, Q, ans[100005], C;
vector<int> pos;
vector<tuple<int, int, int, int>> queries;
tree<pii, null_type, greater<pii>, rb_tree_tag, tree_order_statistics_node_update> st[800005];

void modify(int p, pii v, int i = 1, int L = 0, int R = C)
{
    st[i].insert(v);
    if (L + 1 < R)
    {
        int mid = (L + R) / 2;
        if (p < pos[mid])
            modify(p, v, i << 1, L, mid);
        else
            modify(p, v, i << 1 | 1, mid, R);
    }
}

int query(int p, int c, int i = 1, int L = 0, int R = C)
{
    if (p <= pos[L])
        return st[i].order_of_key(pii(c, 0));
    else
    {
        int mid = (L + R) / 2;
        if (p < pos[mid])
            return query(p, c, i << 1, L, mid) + query(p, c, i << 1 | 1, mid, R);
        else
            return query(p, c, i << 1 | 1, mid, R);
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> N >> Q;
    for (int i = 1; i <= N; i++)
    {
        int S, T;
        cin >> S >> T;
        pos.emplace_back(T);
        queries.emplace_back(make_tuple(S, Q + i, T, 0));
    }
    for (int i = 1; i <= Q; i++)
    {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        pos.emplace_back(Y);
        queries.emplace_back(make_tuple(X, i, Y, Z));
    }
    pos.emplace_back(1'000'000'000);
    sort(pos.begin(), pos.end());
    pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
    C = pos.size();
    sort(queries.begin(), queries.end(), greater<>());
    for (auto [a, i, b, c] : queries)
    {
        // cerr << i << ' ' << a << ' ' << b << ' ' << c << '\n';
        if (i > Q)
            modify(b, pii(a + b, i));
        else
            ans[i] = query(b, c);
    }
    for (int i = 1; i <= Q; i++)
        cout << ans[i] << '\n';
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:66:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   66 |     for (auto [a, i, b, c] : queries)
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 75460 KB Output is correct
2 Correct 56 ms 75512 KB Output is correct
3 Correct 56 ms 75340 KB Output is correct
4 Correct 59 ms 75452 KB Output is correct
5 Correct 57 ms 75460 KB Output is correct
6 Correct 54 ms 75396 KB Output is correct
7 Correct 70 ms 78260 KB Output is correct
8 Correct 69 ms 78248 KB Output is correct
9 Correct 69 ms 78240 KB Output is correct
10 Correct 60 ms 76496 KB Output is correct
11 Correct 72 ms 78300 KB Output is correct
12 Correct 62 ms 76500 KB Output is correct
13 Correct 69 ms 78236 KB Output is correct
14 Correct 73 ms 78284 KB Output is correct
15 Correct 70 ms 78284 KB Output is correct
16 Correct 70 ms 78136 KB Output is correct
17 Correct 58 ms 75980 KB Output is correct
18 Correct 60 ms 76204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1870 ms 189892 KB Output is correct
2 Correct 1826 ms 189864 KB Output is correct
3 Correct 1940 ms 189856 KB Output is correct
4 Correct 387 ms 109488 KB Output is correct
5 Correct 1434 ms 189888 KB Output is correct
6 Correct 403 ms 109440 KB Output is correct
7 Correct 1977 ms 189944 KB Output is correct
8 Correct 1679 ms 187180 KB Output is correct
9 Correct 1692 ms 187196 KB Output is correct
10 Correct 1462 ms 189672 KB Output is correct
11 Correct 264 ms 92708 KB Output is correct
12 Correct 326 ms 98852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1870 ms 189892 KB Output is correct
2 Correct 1826 ms 189864 KB Output is correct
3 Correct 1940 ms 189856 KB Output is correct
4 Correct 387 ms 109488 KB Output is correct
5 Correct 1434 ms 189888 KB Output is correct
6 Correct 403 ms 109440 KB Output is correct
7 Correct 1977 ms 189944 KB Output is correct
8 Correct 1679 ms 187180 KB Output is correct
9 Correct 1692 ms 187196 KB Output is correct
10 Correct 1462 ms 189672 KB Output is correct
11 Correct 264 ms 92708 KB Output is correct
12 Correct 326 ms 98852 KB Output is correct
13 Correct 1981 ms 189888 KB Output is correct
14 Correct 1855 ms 189872 KB Output is correct
15 Correct 1806 ms 189872 KB Output is correct
16 Correct 439 ms 109520 KB Output is correct
17 Correct 1465 ms 189988 KB Output is correct
18 Correct 389 ms 109416 KB Output is correct
19 Correct 1875 ms 189940 KB Output is correct
20 Correct 1897 ms 189916 KB Output is correct
21 Correct 1962 ms 189104 KB Output is correct
22 Correct 1380 ms 189772 KB Output is correct
23 Correct 248 ms 93016 KB Output is correct
24 Correct 308 ms 98816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 75460 KB Output is correct
2 Correct 56 ms 75512 KB Output is correct
3 Correct 56 ms 75340 KB Output is correct
4 Correct 59 ms 75452 KB Output is correct
5 Correct 57 ms 75460 KB Output is correct
6 Correct 54 ms 75396 KB Output is correct
7 Correct 70 ms 78260 KB Output is correct
8 Correct 69 ms 78248 KB Output is correct
9 Correct 69 ms 78240 KB Output is correct
10 Correct 60 ms 76496 KB Output is correct
11 Correct 72 ms 78300 KB Output is correct
12 Correct 62 ms 76500 KB Output is correct
13 Correct 69 ms 78236 KB Output is correct
14 Correct 73 ms 78284 KB Output is correct
15 Correct 70 ms 78284 KB Output is correct
16 Correct 70 ms 78136 KB Output is correct
17 Correct 58 ms 75980 KB Output is correct
18 Correct 60 ms 76204 KB Output is correct
19 Correct 1870 ms 189892 KB Output is correct
20 Correct 1826 ms 189864 KB Output is correct
21 Correct 1940 ms 189856 KB Output is correct
22 Correct 387 ms 109488 KB Output is correct
23 Correct 1434 ms 189888 KB Output is correct
24 Correct 403 ms 109440 KB Output is correct
25 Correct 1977 ms 189944 KB Output is correct
26 Correct 1679 ms 187180 KB Output is correct
27 Correct 1692 ms 187196 KB Output is correct
28 Correct 1462 ms 189672 KB Output is correct
29 Correct 264 ms 92708 KB Output is correct
30 Correct 326 ms 98852 KB Output is correct
31 Correct 1981 ms 189888 KB Output is correct
32 Correct 1855 ms 189872 KB Output is correct
33 Correct 1806 ms 189872 KB Output is correct
34 Correct 439 ms 109520 KB Output is correct
35 Correct 1465 ms 189988 KB Output is correct
36 Correct 389 ms 109416 KB Output is correct
37 Correct 1875 ms 189940 KB Output is correct
38 Correct 1897 ms 189916 KB Output is correct
39 Correct 1962 ms 189104 KB Output is correct
40 Correct 1380 ms 189772 KB Output is correct
41 Correct 248 ms 93016 KB Output is correct
42 Correct 308 ms 98816 KB Output is correct
43 Correct 2033 ms 197632 KB Output is correct
44 Correct 2015 ms 202440 KB Output is correct
45 Correct 2035 ms 202188 KB Output is correct
46 Correct 466 ms 112608 KB Output is correct
47 Correct 1534 ms 200676 KB Output is correct
48 Correct 388 ms 110208 KB Output is correct
49 Correct 2163 ms 202260 KB Output is correct
50 Correct 1962 ms 202288 KB Output is correct
51 Correct 2098 ms 202300 KB Output is correct
52 Correct 1457 ms 200396 KB Output is correct
53 Correct 298 ms 95172 KB Output is correct