QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#599470#9424. Stop the Castle 2ucup-team3099#AC ✓321ms17904kbC++239.0kb2024-09-29 05:17:502024-09-29 05:17:51

Judging History

你现在查看的是最新测评结果

  • [2024-09-29 05:17:51]
  • 评测
  • 测评结果:AC
  • 用时:321ms
  • 内存:17904kb
  • [2024-09-29 05:17:50]
  • 提交

answer

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
#include <queue>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T = int>
class Dinic {
public:
    struct Edge {
        Edge(int a, T b){to = a;cap = b;}
        int to;
        T cap;
    };

    Dinic(int _n) : n(_n) {
        edges.resize(n);
    }

    T maxFlow(int src, int sink) {
        T ans = 0;
        while(bfs(src, sink)) {
            // maybe random shuffle edges against bad cases?
            T flow;
            pt = std::vector<int>(n, 0);
            while((flow = dfs(src, sink))) {
                ans += flow;
            }
        }
        return ans;
    }

    void addEdge(int from, int to, T cap, T other = 0) {
        edges[from].push_back((int) list.size());
        list.push_back(Edge(to, cap));
        edges[to].push_back((int) list.size());
        list.push_back(Edge(from, other));
    }

    bool inCut(int u) const { return h[u] < n; }
    int size() const { return n; }
//private:
    int n;
    std::vector<std::vector<int> > edges;
    std::vector<Edge> list;
    std::vector<int> h, pt;

    T dfs(int on, int sink, T flow = 1e9) {
        if(flow == 0) {
            return 0;
        } if(on == sink) {
            return flow;
        }
        for(; pt[on] < (int) edges[on].size(); pt[on]++) {
            int cur = edges[on][pt[on]];
            if(h[on] + 1 != h[list[cur].to]) {
                continue;
            }
            T got = dfs(list[cur].to, sink, std::min(flow, list[cur].cap));
            if(got) {
                list[cur].cap -= got;
                list[cur ^ 1].cap += got;
                return got;
            }
        }
        return 0;
    }

    bool bfs(int src, int sink) {
        h = std::vector<int>(n, n);
        h[src] = 0;
        std::queue<int> q;
        q.push(src);
        while(!q.empty()) {
            int on = q.front();
            q.pop();
            for(auto a : edges[on]) {
                if(list[a].cap == 0) {
                    continue;
                }
                int to = list[a].to;
                if(h[to] > h[on] + 1) {
                    h[to] = h[on] + 1;
                    q.push(to);
                }
            }
        }
        return h[sink] < n;
    }
};

struct Point {
    int x, y, id, t;

    bool operator < (const Point &o) const { return std::pair<int, int>(x, y) < std::pair<int, int>(o.x, o.y); }
};

void rotate(std::vector<Point> &a) {
    for(auto &stuff : a) {
        std::swap(stuff.x, stuff.y);
    }
}

int ans;

int sz[2];

void findBlocks(std::vector<Point> &p, int t, std::vector<std::pair<int, int>> &ed) {
    std::sort(p.begin(), p.end());
    const int n = (int) p.size();
    for(int l = 0, r = 0; l < n; l = r) {
        r++;
        if(p[l].t == 0) {
            continue;
        }
        while(r < n && p[r].t == 0) {
            r++;
        }
        if(r == n) {
            break;
        }
        if(r - l == 1 && p[l].x == p[r].x) {
            ans++;
        }
        if(r - l > 1 && p[l].x == p[r].x) {
            for(int i = l+1; i < r; i++) {
                //std::cout << "for id " << p[i].id << " at t " << t << " setting to " << sz[t] << std::endl;
                (t == 0 ? ed[p[i].id].first : ed[p[i].id].second) = sz[t];
            }
            sz[t]++;
        }
    }
}

int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
    int t;
    std::cin >> t;
    while(t--) {
        int n, m, k;
        std::cin >> n >> m >> k;
        std::vector<Point> a(n+m);
        ans = 0;
        sz[0] = sz[1] = 0;
        for(int i = 0; i < n+m; i++) {
            std::cin >> a[i].x >> a[i].y;
            a[i].id = i < n ? i : i - n;
            a[i].t = i < n ? 1 : 0;
        }
        std::vector<std::pair<int, int>> blockToRook(m, {-1, -1});
        std::vector<int> id;
        findBlocks(a, 0, blockToRook);
        rotate(a);
        findBlocks(a, 1, blockToRook);
        Dinic<int> graph(sz[0] + sz[1] + 2);
        int src = sz[0] + sz[1];
        int sink = src + 1;
        std::vector<bool> used(m, false);
        std::vector<int> any0(sz[0], -1), any1(sz[1], -1);
        for(int i = 0; i < m; i++) {
            if(blockToRook[i].first != -1 && blockToRook[i].second != -1) {
                id.push_back(i);
                //std::cout << "adding edge (" << blockToRook[i].first << ", " << blockToRook[i].second + sz[0] << ")" << std::endl;
                graph.addEdge(blockToRook[i].first, blockToRook[i].second + sz[0], 1);
            }
            if(blockToRook[i].first != -1) {
                assert(blockToRook[i].first < sz[0]);
                any0[blockToRook[i].first] = i;
            }
            if(blockToRook[i].second != -1) {
                assert(blockToRook[i].second < sz[1]);
                any1[blockToRook[i].second] = i;
            }
        }
        for(int i = 0; i < sz[0]; i++) {
            graph.addEdge(src, i, 1);
        }
        for(int i = 0; i < sz[1]; i++) {
            graph.addEdge(i+sz[0], sink, 1);
        }
        int flow = graph.maxFlow(src, sink);
        int wtf[3] = {m - (sz[1] + sz[0] - flow), sz[1] + sz[0] - 2 * flow, flow};
        //std::cout << "sizes " << sz[0] << ", " << sz[1] << " with flow " << flow << " and base " << ans << '\n';
        if(m - k <= flow) {
            std::cout << "" << ans + sz[1] + sz[0] - 2 * (m - k) << '\n';
        } else if(m - k <= wtf[1] + wtf[2]) {
            std::cout << "" << ans + sz[1] + sz[0] - 2 * flow - ((m - k) - flow) << '\n';
        } else {
            std::cout << ans << "\n";
        }
        std::vector<int> order;
        for(int i = 0; i < (int) id.size(); i++) {
            if(graph.list[2*i].cap == 0) {
                order.push_back(id[i]);
                used[id[i]] = true;
                auto ed = blockToRook[id[i]];
                any0[ed.first] = -1;
                any1[ed.second] = -1;
            }
        }
        for(int x : any0) if(x != -1) {
            order.push_back(x);
            used[x] = true;
        }
        for(int x : any1) if(x != -1) {
            order.push_back(x);
            used[x] = true;
        }
        for(int x = 0; x < m; x++) if(!used[x]) {
            order.push_back(x);
            used[x] = true;
        }
        std::vector<int> kek;
        while(k--) {
            kek.push_back(order.back());
            order.pop_back();
        }
        order = kek;
        for(int i = 0; i < (int) order.size(); i++) {
            std::cout << order[i] + 1 << (i + 1 == (int) order.size() ? '\n' : ' ');
        }
    }
}

/*
NEVER FORGET TO:
    Look at the problem's constraints before coding.
How to cheese cf:
    Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
    If it isn't the answer, have more faith or change to another bound god by looking for a better bound.

    Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.

    You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
    Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
    This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
    https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
    Don't think about them being right or not, cf is a battle of intuition only.

    Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.

    Think about 2x2 cases for matrix problems and hope that everything works for the general case.

    Find a necessary condition and trust it to be sufficient. They're basically the same thing.

    Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.

    For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C

    Consider doing problems in reverse order of queries/updates

    For combinatorics problems, consider symmetry

    For problems that are similar to past problems, think about the differences betweem it and the current problem.
    Sometimes the difference makes no difference. Sometimes it does.

General strategy (MUST DO):
    Try to solve the problem with more restricted constraints.

About testing:
    Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.

This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

3
8 6 4
1 3
2 1
2 6
4 1
4 7
6 1
6 3
6 6
2 3
3 1
4 3
4 6
5 2
6 4
3 2 1
10 12
10 10
10 11
1 4
1 5
1 3 2
1 1
2 1
2 2
2 3

output:

4
5 3 2 6
2
2
0
3 2

result:

ok ok 3 cases (3 test cases)

Test #2:

score: 0
Accepted
time: 55ms
memory: 4920kb

input:

1224
11 17 14
7 3
4 2
8 13
3 15
3 4
5 11
10 2
3 3
8 6
7 11
2 3
10 4
1 3
12 1
2 5
11 9
11 6
11 10
8 15
1 5
9 14
4 11
1 6
10 7
7 6
11 4
8 4
1 11
18 3 2
14 8
2 14
13 13
9 12
14 12
5 6
8 1
10 5
8 6
8 9
6 6
7 5
12 11
6 11
13 5
1 10
7 6
14 5
6 15
2 4
11 1
1 6 4
14 14
13 9
9 3
10 12
7 5
8 13
9 14
1 9 8
4 9...

output:

7
17 16 15 13 12 11 10 9 8 7 6 5 4 3
15
3 2
0
6 5 4 3
0
9 8 7 6 5 4 3 2
11
3 1
8
3 2 1
0
12 11 10 9 8 7 6 5 4 3 2 1
1
12 11 10 9 7 6 5
8
19 18 17
1
8 7 6 5 4 3 2 1
7
8 6
10
15 14 13
1
20 19 18 17 16 15 14 13 12 11 10
0
1
1
3 2
0
7 6 5
7
14 13 12 11 8
2
14 13 12 11 10
4
8 7 6 5 4 3
1
18
1
9 8 7 6 5 4...

result:

ok ok 1224 cases (1224 test cases)

Test #3:

score: 0
Accepted
time: 116ms
memory: 17904kb

input:

1
86289 95092 40401
911 152
1 270
135 731
347 451
283 224
338 348
166 346
12 385
590 763
939 176
232 405
122 946
397 576
795 823
546 392
33 718
444 598
954 852
185 662
732 539
172 681
386 148
76 495
163 323
711 201
278 363
531 275
66 122
823 983
234 792
102 188
985 423
804 712
419 636
318 331
693 68...

output:

81531
95089 95088 95087 95081 95075 95073 95071 95070 95066 95065 95063 95061 95051 95048 95045 95044 95043 95041 95040 95039 95038 95036 95035 95034 95032 95031 95030 95029 95028 95027 95024 95022 95019 95018 95017 95013 95012 95009 95007 95003 95002 95000 94997 94996 94995 94993 94992 94990 94986 ...

result:

ok ok 1 cases (1 test case)

Test #4:

score: 0
Accepted
time: 75ms
memory: 13268kb

input:

1
99057 99722 73893
190482185 274379837
466851670 641324039
993028302 128875937
102891466 286559847
526771097 794238060
565736409 328262657
190329865 598878250
790626887 595298790
308031819 470646878
341575785 374318107
257299536 280924175
64420619 591124604
323023069 811512407
428956686 719615923
2...

output:

82045
99722 99721 99720 99719 99717 99715 99714 99713 99710 99708 99707 99706 99705 99703 99702 99698 99694 99693 99691 99688 99683 99680 99676 99675 99673 99671 99670 99669 99668 99665 99663 99661 99659 99656 99654 99653 99651 99650 99645 99643 99639 99638 99636 99635 99633 99632 99630 99628 99626 ...

result:

ok ok 1 cases (1 test case)

Test #5:

score: 0
Accepted
time: 155ms
memory: 15916kb

input:

1
100000 99990 27662
913840909 999962982
690565691 31053
780601566 31053
54745498 31053
5383 859704869
538124857 999962982
5383 66851413
1444277 31053
119603839 999962982
999833258 543197820
999833258 349576387
999833258 759855830
999833258 124692224
266093388 999962982
5383 100041707
999833258 2843...

output:

100891
99990 99989 99988 99987 99986 99984 99983 99982 99981 99980 99979 99978 99976 99974 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99953 99952 99951 99948 99946 99945 99944 99943 99942 99940 99939 99937 99936 99935 99934 99933 99932...

result:

ok ok 1 cases (1 test case)

Test #6:

score: 0
Accepted
time: 40ms
memory: 11672kb

input:

1
100000 49997 21428
9380 4333
9380 999999628
49202 4333
49202 999999628
50841 4333
50841 999999628
77418 4333
77418 999999628
95722 4333
95722 999999628
144002 4333
144002 999999628
234359 4333
234359 999999628
268942 4333
268942 999999628
288956 4333
288956 999999628
415094 4333
415094 999999628
4...

output:

100000
49997 49996 49995 49994 49993 49992 49990 49986 49985 49984 49983 49981 49980 49979 49977 49976 49974 49970 49968 49967 49965 49964 49962 49961 49960 49959 49958 49957 49955 49951 49950 49949 49947 49946 49945 49944 49942 49938 49935 49934 49933 49932 49931 49928 49927 49926 49925 49922 49921...

result:

ok ok 1 cases (1 test case)

Test #7:

score: 0
Accepted
time: 43ms
memory: 12480kb

input:

1
100000 100000 76259
931427170 7
367311884 7
646435086 7
925372747 7
371054451 7
284185575 7
695090232 7
889183241 7
615617158 7
44230096 7
293281406 7
758261641 7
685549291 7
679471071 7
723138327 7
901136691 7
49281635 7
256352978 7
320188290 7
78730802 7
788131872 7
234735044 7
664906524 7
79430...

output:

76258
99737 99700 99650 99640 99530 99514 99428 99169 99065 99015 98937 98838 98815 98779 98754 98734 98693 98686 98534 98532 98525 98490 98435 98429 98349 98347 98342 98276 98245 98237 98234 98038 98008 97998 97992 97928 97920 97904 97891 97874 97866 97861 97857 97828 97818 97815 97807 97805 97714 ...

result:

ok ok 1 cases (1 test case)

Test #8:

score: 0
Accepted
time: 36ms
memory: 11700kb

input:

1
100000 49999 24999
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

99996
49998 49995 49992 49989 49986 49983 49980 49977 49974 49971 49968 49965 49962 49959 49956 49953 49950 49947 49944 49941 49938 49935 49932 49929 49926 49923 49920 49917 49914 49911 49908 49905 49902 49899 49896 49893 49890 49887 49884 49881 49878 49875 49872 49869 49866 49863 49860 49857 49854 ...

result:

ok ok 1 cases (1 test case)

Test #9:

score: 0
Accepted
time: 92ms
memory: 7272kb

input:

556
16 6 3
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
1 2
1000000000 2
1 3
1000000000 3
1 4
1000000000 4
1 5
1000000000 5
1 6
1000000000 6
2 3
3 3
3 2
4 2
2 4
4 4
32 12 6
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 ...

output:

14
5 4 2
32
12 11 10 5 4 2
31
15 13 12 10 9 4 2 1
8
1
13
3 1
19
9 8 7 5 4
11
6 5 1
20
6 5 3
15
7 6 4 3
33
14 12 10 9 8 6 4
31
16 13 12 11 9 7 6 4
19
8 7 4 3 2
31
10 9 6 5 2
15
7 6 2 1
28
9 5 3 2 1
11
1
19
9 8 6 4 1
23
12 10 9 6 5 1
34
16 14 13 12 11 10 7 1
31
14 13 12 9 8 7 5 3
29
12 7 6 5 4 2
17
6 ...

result:

ok ok 556 cases (556 test cases)

Test #10:

score: 0
Accepted
time: 321ms
memory: 12864kb

input:

1
100000 50000 25000
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

99996
50000 49994 49992 49991 49990 49989 49988 49987 49986 49985 49981 49977 49976 49974 49972 49967 49966 49964 49963 49959 49955 49954 49953 49951 49950 49948 49946 49944 49943 49941 49938 49935 49930 49929 49927 49921 49917 49916 49914 49913 49910 49909 49906 49902 49899 49897 49894 49893 49889 ...

result:

ok ok 1 cases (1 test case)

Test #11:

score: 0
Accepted
time: 29ms
memory: 7032kb

input:

556
32 15 7
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
1 2
1000000000 2
1 3
1000000000 3
1 4
1000000000 4
1 5
1000000000 5
1 6
1000000000 6
1 7
1000000000 7
1 8
1000000000 8
1 9
1000000000 9
7 6
4 3
5 4
2 2
...

output:

28
15 10 8 7 3 2 1
11
4 1
20
4 3
23
10 9 8 7 4
26
8 7 6 2 1
17
1
10
2
31
8 6 3 2
14
1
31
14 11 7 5 4 3 2
34
15 8 7 5 4 3 2
16
3
32
8 7 6 2 1
29
5 3
28
15 12 10 8 7 6 1
31
14 8 6 5 4 2 1
25
9 8 5 3
15
5 4 2
29
11 9 6 5 1
31
8 7 4 1
15
7 2 1
29
3 1
27
6 3 1
19
9 7 6 5
25
9 7 6 1
2
1
16
2
32
15 14 13 1...

result:

ok ok 556 cases (556 test cases)

Test #12:

score: 0
Accepted
time: 37ms
memory: 11708kb

input:

1
100000 49999 24999
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

99996
49998 49996 49991 49990 49987 49984 49983 49981 49980 49979 49978 49976 49975 49972 49971 49970 49969 49964 49961 49960 49959 49956 49954 49950 49949 49946 49945 49944 49943 49941 49940 49938 49937 49936 49933 49932 49931 49929 49928 49927 49926 49918 49912 49911 49910 49908 49906 49902 49900 ...

result:

ok ok 1 cases (1 test case)

Test #13:

score: 0
Accepted
time: 93ms
memory: 7036kb

input:

556
22 1 1
2 1
2 1000000000
1 2
1000000000 2
1 3
1000000000 3
1 4
1000000000 4
1 5
1000000000 5
1 6
1000000000 6
1 7
1000000000 7
1 8
1000000000 8
1 9
1000000000 9
1 10
1000000000 10
1 11
1000000000 11
2 2
18 3 1
2 1
2 1000000000
3 1
3 1000000000
1 2
1000000000 2
1 3
1000000000 3
1 4
1000000000 4
1 ...

output:

29
1
19
1
20
5 1
14
5 2
25
2
28
9 8 6 4 3 2 1
23
1
29
11 10 8 5 3
28
6 5 3 2
5
1
23
11 9 8 7 6
31
15 14 13 10 5 3 2
29
3 2
7
1
26
1
27
13 12 9 6 3 2
24
7 5 1
14
5 3
32
14 13 11 10 6 5 4 3
24
5 2 1
27
10 7 6 3 2 1
32
15 14 9 5 4 3 2 1
30
5 3 1
24
7 3 2
15
6 3 2
26
1
18
6 2 1
22
2
34
15 14 11 8 7 6 5
...

result:

ok ok 556 cases (556 test cases)

Test #14:

score: 0
Accepted
time: 310ms
memory: 12436kb

input:

1
100000 49999 24999
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

99996
49997 49996 49994 49992 49990 49989 49988 49986 49984 49982 49980 49978 49977 49972 49971 49970 49966 49965 49964 49961 49959 49957 49954 49953 49950 49949 49948 49946 49944 49943 49942 49940 49937 49935 49934 49931 49930 49929 49926 49925 49924 49923 49921 49920 49918 49917 49915 49914 49910 ...

result:

ok ok 1 cases (1 test case)

Test #15:

score: 0
Accepted
time: 111ms
memory: 10928kb

input:

1
100000 49998 34141
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

118282
49997 49996 49995 49994 49992 49991 49990 49988 49983 49982 49979 49978 49977 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49960 49956 49955 49954 49952 49951 49950 49948 49947 49946 49944 49943 49942 49940 49939 49938 49936 49932 49930 49929 49928 49925 49923 49922...

result:

ok ok 1 cases (1 test case)

Test #16:

score: 0
Accepted
time: 72ms
memory: 14020kb

input:

1
100000 82275 67072
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

119590
82275 82274 82273 82269 82266 82261 82252 82251 82246 82240 82239 82236 82234 82233 82230 82229 82227 82224 82223 82222 82221 82218 82217 82216 82214 82213 82212 82209 82207 82206 82205 82204 82203 82202 82201 82200 82197 82196 82193 82192 82191 82190 82186 82185 82184 82182 82181 82179 82176...

result:

ok ok 1 cases (1 test case)

Test #17:

score: 0
Accepted
time: 77ms
memory: 8056kb

input:

556
30 12 6
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
1 2
1000000000 2
1 3
1000000000 3
1 4
1000000000 4
1 5
1000000000 5
1 6
1000000000 6
1 7
1000000000 7
1 8
1000000000 8
1 9
1000000000 9
2 6
2 8
3 4
4 4
4 8
5 3
5 7
5 8
6...

output:

29
11 10 8 4 2 7
19
10 8 6 3 2 11 9 7 5
25
6 4 3 12 11 5 10 9 8 2
13
3 4 5
31
26 24 23 22 20 18 17 16 14 13 12 11 9 8 6 5 3 2 28 27 25 21 19
36
9 8 4 1 5 13 10
18
5 4 3 2
20
6 3 8 7 4
20
14 13 11 10 9 8 6 5 4 3 2 18 12 17 16
12
5 4 3 2
8
8 7 6 4 3 2
15
6 5 4 3 2
22
17 16 15 13 11 9 8 6 5 3 2 12 7
25...

result:

ok ok 556 cases (556 test cases)

Test #18:

score: 0
Accepted
time: 171ms
memory: 15668kb

input:

1
100000 99991 75553
2 1
2 1000000000
3 1
3 1000000000
4 1
4 1000000000
5 1
5 1000000000
6 1
6 1000000000
7 1
7 1000000000
8 1
8 1000000000
9 1
9 1000000000
10 1
10 1000000000
11 1
11 1000000000
12 1
12 1000000000
13 1
13 1000000000
14 1
14 1000000000
15 1
15 1000000000
16 1
16 1000000000
17 1
17 10...

output:

101120
99990 99989 99988 99987 99986 99984 99983 99982 99981 99978 99977 99976 99974 99973 99972 99971 99969 99967 99966 99965 99964 99963 99961 99960 99959 99958 99957 99955 99954 99952 99951 99950 99949 99947 99946 99944 99943 99942 99941 99938 99937 99936 99934 99933 99930 99929 99928 99927 99924...

result:

ok ok 1 cases (1 test case)

Extra Test:

score: 0
Extra Test Passed