QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#521562#4930. LCS of Permutationsskittles1412#38 406ms16396kbC++176.4kb2024-08-16 12:12:482024-08-16 12:12:48

Judging History

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

  • [2024-08-16 12:12:48]
  • 评测
  • 测评结果:38
  • 用时:406ms
  • 内存:16396kb
  • [2024-08-16 12:12:48]
  • 提交

answer

// cf bits/extc++.h nonsense
#ifdef ONLINE_JUDGE
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#endif
#include "bits/extc++.h"

using namespace std;

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t;
    ((cerr << " | " << u), ...);
    cerr << endl;
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

using u64 = uint64_t;
using ll = long long;
using ld = long double;

template <typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))

inline void init_io() {
    cin.tie(nullptr);
    cin.exceptions(ios::failbit);
    ios_base::sync_with_stdio(false);
}

template <typename T>
vector<T> iota(int n, const T& init) {
    vector<T> arr(n);

    iota(begin(arr), end(arr), init);

    return arr;
}

template <typename T>
vector<vector<T>> transposed(const vector<vector<T>>& arr) {
    int n = sz(arr), m = sz(arr[0]);

    vector ans(m, vector<T>(n));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            ans[j][i] = arr[i][j];
        }
    }

    return ans;
}

template <typename T>
bool on(const T& mask, int bit) {
    return (mask >> bit) & 1;
}

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
    out << "[";
    for (int i = 0; i < sz(arr); i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename T, size_t N>
ostream& operator<<(ostream& out, const array<T, N>& arr) {
    out << "[";
    for (int i = 0; i < sz(arr); i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}

template <typename A, typename T>
int lbs(const A& arr, const T& x) {
    return int(lower_bound(begin(arr), end(arr), x) - begin(arr));
}

inline vector<bool>::reference& operator&=(vector<bool>::reference&& a, bool b) {
    return a = a & b;
}

template <typename T>
T reversed(T arr) {
    reverse(begin(arr), end(arr));
    return arr;
}

int lcs(const vector<int>& arra, const vector<int>& arrb) {
    int n = sz(arra), m = sz(arrb);

    vector dp(n + 1, vector(m + 1, 0));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            if (arra[i] == arrb[j]) {
                dp[i][j] = max(dp[i][j], 1 + dp[i + 1][j + 1]);
            }
        }
    }

    return dp[0][0];
}

struct Solver {
    int n, m;
    vector<vector<int>> perms, dist;

    Solver() {}
    Solver(int n) : n(n) {
        {
            auto carr = iota(n, 0);
            do {
                perms.push_back(carr);
            } while (next_permutation(begin(carr), end(carr)));
        }

        m = sz(perms);
        dist = vector(m, vector(m, int(0)));
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                dist[i][j] = lcs(perms[i], perms[j]);
            }
        }
    }

    array<vector<int>, 3> solve(int a, int b, int c) {
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                if (dist[0][i] == a && dist[0][j] == b && dist[i][j] == c) {
                    return {perms[0], perms[i], perms[j]};
                }
            }
        }
        return {};
    }
};

vector<Solver> solvers = []() {
    vector<Solver> ans(7);
    for (int i = 1; i <= 6; i++) {
        ans[i] = Solver(i);
    }
    return ans;
}();

void solve() {
    int n, ka, kb, kc, t_out;
    cin >> n >> ka >> kb >> kc >> t_out;

    auto print_line = [&](const vector<int>& arr) -> void {
        assert(*min_element(begin(arr), end(arr)) == 0);
        assert(*max_element(begin(arr), end(arr)) == n - 1);
        assert(sz(set(begin(arr), end(arr))) == n);
        for (int i = 0; i < n; i++) {
            cout << arr[i] + 1 << " \n"[i == n - 1];
        }
    };

    if (ka == 1 && kb == 1 && kc == n && t_out) {
        cout << "YES" << endl;
        print_line(reversed(iota(n, 0)));
        print_line(iota(n, 0));
        print_line(iota(n, 0));
        return;
    }

    if (kc == n && t_out) {
        if (ka != kb) {
            cout << "NO" << endl;
            return;
        }
        cout << "YES" << endl;

        auto v1 = reversed(iota(n, 0));
        reverse(begin(v1), begin(v1) + ka);
        print_line(v1);
        print_line(iota(n, 0));
        print_line(iota(n, 0));
        return;
    }

    if (ka == 1 && t_out) {
        if (long(kb) * kc < n || kb + kc - 1 > n) {
            cout << "NO" << endl;
            return;
        }

        auto v1 = reversed(iota(n, 0));
        dbg(v1);
        int clen = 0, ci = 0;
        while (true) {
            assert(ci < n);
            clen++;
            int cr = min(n, ci + kb);
            if (clen + n - cr <= kc) {
                cr = clen + n - kc;
                reverse(begin(v1) + ci, begin(v1) + cr);
                break;
            }
            reverse(begin(v1) + ci, begin(v1) + cr);
            ci = cr;
        }

        cout << "YES" << endl;
        print_line(iota(n, 0));
        print_line(reversed(iota(n, 0)));
        print_line(v1);
        return;
    }

    if (n <= 6) {
        if (ka == 1 && (long(kb) * kc < n || kb + kc - 1 > n)) {
            auto ans = solvers[n].solve(ka, kb, kc);
            assert(!sz(ans[0]));
            cout << "NO" << endl;
            return;
        }
        auto ans = solvers[n].solve(ka, kb, kc);
        if (!sz(ans[0])) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
            if (t_out) {
                for (auto& a : ans) {
                    print_line(a);
                }
            }
        }
        return;
    }
}

int main() {
    init_io();
    int tcs;
    cin >> tcs;
    while (tcs--) {
        solve();
    }
}

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 153ms
memory: 6132kb

input:

632
512 1 1 512 1
201 1 1 201 1
155 1 1 155 1
129 1 1 129 1
345 1 1 345 1
454 1 1 454 1
614 1 1 614 1
11 1 1 11 1
492 1 1 492 1
357 1 1 357 1
300 1 1 300 1
295 1 1 295 1
607 1 1 607 1
442 1 1 442 1
14 1 1 14 1
79 1 1 79 1
584 1 1 584 1
431 1 1 431 1
343 1 1 343 1
64 1 1 64 1
548 1 1 548 1
101 1 1 10...

output:

YES
512 511 510 509 508 507 506 505 504 503 502 501 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 ...

result:

ok Correct (632 test cases)

Test #2:

score: 3
Accepted
time: 189ms
memory: 15916kb

input:

1
200000 1 1 200000 1

output:

YES
200000 199999 199998 199997 199996 199995 199994 199993 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199961 199960 199959 19...

result:

ok Correct (1 test case)

Test #3:

score: 3
Accepted
time: 184ms
memory: 11360kb

input:

2
118278 1 1 118278 1
81722 1 1 81722 1

output:

YES
118278 118277 118276 118275 118274 118273 118272 118271 118270 118269 118268 118267 118266 118265 118264 118263 118262 118261 118260 118259 118258 118257 118256 118255 118254 118253 118252 118251 118250 118249 118248 118247 118246 118245 118244 118243 118242 118241 118240 118239 118238 118237 11...

result:

ok Correct (2 test cases)

Test #4:

score: 3
Accepted
time: 183ms
memory: 10756kb

input:

5
24223 1 1 24223 1
41513 1 1 41513 1
15442 1 1 15442 1
19470 1 1 19470 1
99352 1 1 99352 1

output:

YES
24223 24222 24221 24220 24219 24218 24217 24216 24215 24214 24213 24212 24211 24210 24209 24208 24207 24206 24205 24204 24203 24202 24201 24200 24199 24198 24197 24196 24195 24194 24193 24192 24191 24190 24189 24188 24187 24186 24185 24184 24183 24182 24181 24180 24179 24178 24177 24176 24175 24...

result:

ok Correct (5 test cases)

Test #5:

score: 3
Accepted
time: 170ms
memory: 8224kb

input:

20
11481 1 1 11481 1
53318 1 1 53318 1
13359 1 1 13359 1
8929 1 1 8929 1
15918 1 1 15918 1
509 1 1 509 1
11385 1 1 11385 1
10829 1 1 10829 1
5628 1 1 5628 1
1270 1 1 1270 1
2232 1 1 2232 1
3011 1 1 3011 1
4020 1 1 4020 1
23225 1 1 23225 1
215 1 1 215 1
1094 1 1 1094 1
10463 1 1 10463 1
708 1 1 708 1...

output:

YES
11481 11480 11479 11478 11477 11476 11475 11474 11473 11472 11471 11470 11469 11468 11467 11466 11465 11464 11463 11462 11461 11460 11459 11458 11457 11456 11455 11454 11453 11452 11451 11450 11449 11448 11447 11446 11445 11444 11443 11442 11441 11440 11439 11438 11437 11436 11435 11434 11433 11...

result:

ok Correct (20 test cases)

Test #6:

score: 3
Accepted
time: 165ms
memory: 6052kb

input:

100
1273 1 1 1273 1
1503 1 1 1503 1
2935 1 1 2935 1
4875 1 1 4875 1
2328 1 1 2328 1
2048 1 1 2048 1
4128 1 1 4128 1
2855 1 1 2855 1
6624 1 1 6624 1
2447 1 1 2447 1
2266 1 1 2266 1
1875 1 1 1875 1
2960 1 1 2960 1
2432 1 1 2432 1
8 1 1 8 1
516 1 1 516 1
127 1 1 127 1
5844 1 1 5844 1
2060 1 1 2060 1
10...

output:

YES
1273 1272 1271 1270 1269 1268 1267 1266 1265 1264 1263 1262 1261 1260 1259 1258 1257 1256 1255 1254 1253 1252 1251 1250 1249 1248 1247 1246 1245 1244 1243 1242 1241 1240 1239 1238 1237 1236 1235 1234 1233 1232 1231 1230 1229 1228 1227 1226 1225 1224 1223 1222 1221 1220 1219 1218 1217 1216 1215 1...

result:

ok Correct (100 test cases)

Test #7:

score: 3
Accepted
time: 149ms
memory: 5792kb

input:

10000
13 1 1 13 1
2 1 1 2 1
43 1 1 43 1
5 1 1 5 1
19 1 1 19 1
20 1 1 20 1
15 1 1 15 1
2 1 1 2 1
68 1 1 68 1
9 1 1 9 1
6 1 1 6 1
40 1 1 40 1
6 1 1 6 1
40 1 1 40 1
12 1 1 12 1
21 1 1 21 1
38 1 1 38 1
26 1 1 26 1
1 1 1 1 1
18 1 1 18 1
59 1 1 59 1
16 1 1 16 1
12 1 1 12 1
2 1 1 2 1
12 1 1 12 1
1 1 1 1 1
...

output:

YES
13 12 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
YES
2 1
1 2
1 2
YES
43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...

result:

ok Correct (10000 test cases)

Test #8:

score: 3
Accepted
time: 164ms
memory: 5840kb

input:

50000
2 1 1 2 1
3 1 1 3 1
5 1 1 5 1
1 1 1 1 1
5 1 1 5 1
2 1 1 2 1
2 1 1 2 1
2 1 1 2 1
2 1 1 2 1
6 1 1 6 1
4 1 1 4 1
3 1 1 3 1
4 1 1 4 1
1 1 1 1 1
2 1 1 2 1
2 1 1 2 1
3 1 1 3 1
3 1 1 3 1
2 1 1 2 1
10 1 1 10 1
1 1 1 1 1
1 1 1 1 1
6 1 1 6 1
1 1 1 1 1
6 1 1 6 1
1 1 1 1 1
5 1 1 5 1
14 1 1 14 1
1 1 1 1 1
...

output:

YES
2 1
1 2
1 2
YES
3 2 1
1 2 3
1 2 3
YES
5 4 3 2 1
1 2 3 4 5
1 2 3 4 5
YES
1
1
1
YES
5 4 3 2 1
1 2 3 4 5
1 2 3 4 5
YES
2 1
1 2
1 2
YES
2 1
1 2
1 2
YES
2 1
1 2
1 2
YES
2 1
1 2
1 2
YES
6 5 4 3 2 1
1 2 3 4 5 6
1 2 3 4 5 6
YES
4 3 2 1
1 2 3 4
1 2 3 4
YES
3 2 1
1 2 3
1 2 3
YES
4 3 2 1
1 2 3 4
1 2 3 4
YE...

result:

ok Correct (50000 test cases)

Subtask #2:

score: 8
Accepted

Test #9:

score: 8
Accepted
time: 406ms
memory: 5768kb

input:

40011
1 1 1 1 1
2 1 1 1 1
2 1 1 2 1
2 1 2 2 1
2 2 2 2 1
3 1 1 1 1
3 1 1 2 1
3 1 1 3 1
3 1 2 2 1
3 1 2 3 1
3 1 3 3 1
3 2 2 2 1
3 2 2 3 1
3 2 3 3 1
3 3 3 3 1
4 1 1 1 1
4 1 1 2 1
4 1 1 3 1
4 1 1 4 1
4 1 2 2 1
4 1 2 3 1
4 1 2 4 1
4 1 3 3 1
4 1 3 4 1
4 1 4 4 1
4 2 2 2 1
4 2 2 3 1
4 2 2 4 1
4 2 3 3 1
4 2 ...

output:

YES
1
1
1
NO
YES
2 1
1 2
1 2
NO
YES
1 2
1 2
1 2
NO
NO
YES
3 2 1
1 2 3
1 2 3
YES
1 2 3
3 2 1
2 3 1
NO
NO
YES
1 2 3
1 3 2
2 1 3
YES
2 3 1
1 2 3
1 2 3
NO
YES
1 2 3
1 2 3
1 2 3
NO
NO
NO
YES
4 3 2 1
1 2 3 4
1 2 3 4
YES
1 2 3 4
4 3 2 1
3 4 1 2
YES
1 2 3 4
4 3 2 1
3 4 2 1
NO
NO
NO
NO
YES
1 2 3 4
1 4 3 2
2 ...

result:

ok Correct (40011 test cases)

Subtask #3:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #10:

score: 10
Accepted
time: 118ms
memory: 5832kb

input:

7545
31 1 4 31 1
15 8 13 15 1
34 12 18 34 1
9 1 9 9 1
28 5 12 28 1
21 1 11 21 1
33 9 11 33 1
28 10 14 28 1
33 30 30 33 1
33 19 31 33 1
31 2 25 31 1
24 13 18 24 1
22 11 16 22 1
33 20 20 33 1
28 7 8 28 1
31 5 28 31 1
30 17 18 30 1
22 3 9 22 1
12 6 12 12 1
30 7 21 30 1
31 3 10 31 1
34 24 27 34 1
35 21 ...

output:

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

result:

ok Correct (7545 test cases)

Test #11:

score: 10
Accepted
time: 183ms
memory: 16316kb

input:

1
200000 46236 46236 200000 1

output:

YES
153765 153766 153767 153768 153769 153770 153771 153772 153773 153774 153775 153776 153777 153778 153779 153780 153781 153782 153783 153784 153785 153786 153787 153788 153789 153790 153791 153792 153793 153794 153795 153796 153797 153798 153799 153800 153801 153802 153803 153804 153805 153806 15...

result:

ok Correct (1 test case)

Test #12:

score: 10
Accepted
time: 157ms
memory: 16316kb

input:

1
200000 199998 199998 200000 1

output:

YES
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok Correct (1 test case)

Test #13:

score: 10
Accepted
time: 113ms
memory: 6072kb

input:

1
200000 73211 119733 200000 1

output:

NO

result:

ok Correct (1 test case)

Test #14:

score: 10
Accepted
time: 162ms
memory: 16316kb

input:

1
200000 200000 200000 200000 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (1 test case)

Test #15:

score: 10
Accepted
time: 182ms
memory: 16360kb

input:

1
200000 17422 17422 200000 1

output:

YES
182579 182580 182581 182582 182583 182584 182585 182586 182587 182588 182589 182590 182591 182592 182593 182594 182595 182596 182597 182598 182599 182600 182601 182602 182603 182604 182605 182606 182607 182608 182609 182610 182611 182612 182613 182614 182615 182616 182617 182618 182619 182620 18...

result:

ok Correct (1 test case)

Test #16:

score: 10
Accepted
time: 154ms
memory: 16376kb

input:

1
200000 199997 199997 200000 1

output:

YES
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 10...

result:

ok Correct (1 test case)

Test #17:

score: 10
Accepted
time: 110ms
memory: 5732kb

input:

1
200000 24843 82406 200000 1

output:

NO

result:

ok Correct (1 test case)

Test #18:

score: 10
Accepted
time: 158ms
memory: 16276kb

input:

1
200000 200000 200000 200000 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (1 test case)

Test #19:

score: 10
Accepted
time: 173ms
memory: 14788kb

input:

2
171916 1 1 171916 1
28084 1140 25963 28084 1

output:

YES
171916 171915 171914 171913 171912 171911 171910 171909 171908 171907 171906 171905 171904 171903 171902 171901 171900 171899 171898 171897 171896 171895 171894 171893 171892 171891 171890 171889 171888 171887 171886 171885 171884 171883 171882 171881 171880 171879 171878 171877 171876 171875 17...

result:

ok Correct (2 test cases)

Test #20:

score: 10
Accepted
time: 145ms
memory: 11048kb

input:

2
103116 45915 45915 103116 1
96884 64304 83444 96884 1

output:

YES
57202 57203 57204 57205 57206 57207 57208 57209 57210 57211 57212 57213 57214 57215 57216 57217 57218 57219 57220 57221 57222 57223 57224 57225 57226 57227 57228 57229 57230 57231 57232 57233 57234 57235 57236 57237 57238 57239 57240 57241 57242 57243 57244 57245 57246 57247 57248 57249 57250 57...

result:

ok Correct (2 test cases)

Test #21:

score: 10
Accepted
time: 188ms
memory: 14744kb

input:

2
23087 20700 20700 23087 1
176913 1 1 176913 1

output:

YES
2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2...

result:

ok Correct (2 test cases)

Test #22:

score: 10
Accepted
time: 175ms
memory: 12880kb

input:

2
143057 1 1 143057 1
56943 56943 56943 56943 1

output:

YES
143057 143056 143055 143054 143053 143052 143051 143050 143049 143048 143047 143046 143045 143044 143043 143042 143041 143040 143039 143038 143037 143036 143035 143034 143033 143032 143031 143030 143029 143028 143027 143026 143025 143024 143023 143022 143021 143020 143019 143018 143017 143016 14...

result:

ok Correct (2 test cases)

Test #23:

score: 10
Accepted
time: 165ms
memory: 13308kb

input:

2
63028 63026 63026 63028 1
136972 80745 80745 136972 1

output:

YES
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok Correct (2 test cases)

Test #24:

score: 10
Accepted
time: 157ms
memory: 10180kb

input:

5
24325 12027 20928 24325 1
33551 33551 33551 33551 1
91848 1 1 91848 1
16722 2 2 16722 1
33554 17593 32887 33554 1

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (5 test cases)

Test #25:

score: 10
Accepted
time: 160ms
memory: 9992kb

input:

5
86417 5681 5681 86417 1
570 3 3 570 1
32040 10134 10134 32040 1
51708 51704 51704 51708 1
29265 12195 16608 29265 1

output:

YES
80737 80738 80739 80740 80741 80742 80743 80744 80745 80746 80747 80748 80749 80750 80751 80752 80753 80754 80755 80756 80757 80758 80759 80760 80761 80762 80763 80764 80765 80766 80767 80768 80769 80770 80771 80772 80773 80774 80775 80776 80777 80778 80779 80780 80781 80782 80783 80784 80785 80...

result:

ok Correct (5 test cases)

Test #26:

score: 10
Accepted
time: 159ms
memory: 11384kb

input:

5
2977 1 1 2977 1
3411 3411 3411 3411 1
8955 8955 8955 8955 1
110370 110370 110370 110370 1
74287 74283 74283 74287 1

output:

YES
2977 2976 2975 2974 2973 2972 2971 2970 2969 2968 2967 2966 2965 2964 2963 2962 2961 2960 2959 2958 2957 2956 2955 2954 2953 2952 2951 2950 2949 2948 2947 2946 2945 2944 2943 2942 2941 2940 2939 2938 2937 2936 2935 2934 2933 2932 2931 2930 2929 2928 2927 2926 2925 2924 2923 2922 2921 2920 2919 2...

result:

ok Correct (5 test cases)

Test #27:

score: 10
Accepted
time: 161ms
memory: 7964kb

input:

20
1300 883 883 1300 1
2409 2409 2409 2409 1
22980 22980 22980 22980 1
15455 4 4 15455 1
24568 24568 24568 24568 1
322 322 322 322 1
4398 1 1 4398 1
8257 1956 1956 8257 1
10315 1659 1659 10315 1
45979 1 1 45979 1
1262 285 285 1262 1
11356 1397 1397 11356 1
12392 7768 7768 12392 1
2809 2809 2809 2809...

output:

YES
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 ...

result:

ok Correct (20 test cases)

Test #28:

score: 10
Accepted
time: 153ms
memory: 7340kb

input:

20
16303 11310 11310 16303 1
4345 1 1 4345 1
5817 1657 4906 5817 1
5251 5251 5251 5251 1
28284 12365 14700 28284 1
35999 35999 35999 35999 1
10283 8857 8857 10283 1
5202 2591 2591 5202 1
6800 1 1 6800 1
5395 3076 3271 5395 1
1027 57 57 1027 1
47 47 47 47 1
11249 11247 11247 11249 1
579 441 441 579 1...

output:

YES
4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5...

result:

ok Correct (20 test cases)

Test #29:

score: 10
Accepted
time: 154ms
memory: 6212kb

input:

100
1273 1248 1248 1273 1
1503 1 1 1503 1
2935 1 1 2935 1
4875 4875 4875 4875 1
2328 1 1 2328 1
2048 1764 1764 2048 1
4128 4128 4128 4128 1
2855 593 593 2855 1
6624 1904 1904 6624 1
2447 2415 2415 2447 1
2266 1879 1998 2266 1
1875 1837 1837 1875 1
2960 2956 2956 2960 1
2432 1661 1661 2432 1
8 4 4 8 ...

output:

YES
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 11...

result:

ok Correct (100 test cases)

Test #30:

score: 10
Accepted
time: 142ms
memory: 5968kb

input:

1000
309 32 93 309 1
311 4 4 311 1
144 1 1 144 1
131 131 131 131 1
317 317 317 317 1
77 77 77 77 1
45 1 1 45 1
180 180 180 180 1
86 1 1 86 1
100 15 15 100 1
210 91 91 210 1
256 73 73 256 1
123 64 64 123 1
220 216 216 220 1
359 359 359 359 1
30 29 29 30 1
142 142 142 142 1
74 3 3 74 1
292 292 292 292...

output:

NO
YES
308 309 310 311 307 306 305 304 303 302 301 300 299 298 297 296 295 294 293 292 291 290 289 288 287 286 285 284 283 282 281 280 279 278 277 276 275 274 273 272 271 270 269 268 267 266 265 264 263 262 261 260 259 258 257 256 255 254 253 252 251 250 249 248 247 246 245 244 243 242 241 240 239 2...

result:

ok Correct (1000 test cases)

Test #31:

score: 10
Accepted
time: 142ms
memory: 5856kb

input:

10000
13 13 13 13 1
2 2 2 2 1
43 32 32 43 1
5 4 4 5 1
19 3 3 19 1
20 5 8 20 1
15 12 12 15 1
2 1 1 2 1
68 4 4 68 1
9 8 8 9 1
6 5 5 6 1
40 40 40 40 1
6 1 1 6 1
40 17 17 40 1
12 1 1 12 1
21 20 20 21 1
38 1 1 38 1
26 26 26 26 1
1 1 1 1 1
18 16 16 18 1
59 1 1 59 1
16 8 8 16 1
12 9 9 12 1
2 2 2 2 1
12 5 5...

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
YES
1 2
1 2
1 2
YES
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...

result:

ok Correct (10000 test cases)

Test #32:

score: 10
Accepted
time: 148ms
memory: 5776kb

input:

20000
9 9 9 9 1
5 2 2 5 1
1 1 1 1 1
3 1 1 3 1
15 1 1 15 1
16 13 13 16 1
6 3 3 6 1
1 1 1 1 1
27 1 1 27 1
24 24 24 24 1
5 5 5 5 1
3 1 1 3 1
26 26 26 26 1
2 1 1 2 1
12 1 1 12 1
3 1 1 3 1
5 1 1 5 1
9 9 9 9 1
22 3 3 22 1
15 2 2 15 1
2 1 1 2 1
8 6 6 8 1
1 1 1 1 1
5 5 5 5 1
15 4 4 15 1
15 1 1 15 1
16 5 5 1...

output:

YES
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
YES
4 5 3 2 1
1 2 3 4 5
1 2 3 4 5
YES
1
1
1
YES
3 2 1
1 2 3
1 2 3
YES
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
YES
4 5 6 7 8 9 10 11 12 13 14 15 16 3 2 1
1 2 3 4 5 6 7 8 9 10 ...

result:

ok Correct (20000 test cases)

Test #33:

score: 10
Accepted
time: 172ms
memory: 5832kb

input:

100000
1 1 1 1 1
2 2 2 2 1
1 1 1 1 1
1 1 1 1 1
7 7 7 7 1
3 1 1 3 1
2 2 2 2 1
3 1 1 3 1
2 1 1 2 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
3 1 1 3 1
1 1 1 1 1
1 1 1 1 1
2 2 2 2 1
1 1 1 1 1
4 1 1 4 1
2 1 1 2 1
2 1 1 2 1
1 1 1 1 1
1 1 1 1 1
3 2 2 3 1
1 1 1 1 1
2 2 2 2 1
4 4 4 4 1
1 1 1 1 1
3 2 2 3 1
1 1 1 1 1
1 1...

output:

YES
1
1
1
YES
1 2
1 2
1 2
YES
1
1
1
YES
1
1
1
YES
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
YES
3 2 1
1 2 3
1 2 3
YES
1 2
1 2
1 2
YES
3 2 1
1 2 3
1 2 3
YES
2 1
1 2
1 2
YES
1
1
1
YES
1
1
1
YES
1
1
1
YES
3 2 1
1 2 3
1 2 3
YES
1
1
1
YES
1
1
1
YES
1 2
1 2
1 2
YES
1
1
1
YES
4 3 2 1
1 2 3 4
1 2 3 4
YES
2 ...

result:

ok Correct (100000 test cases)

Subtask #4:

score: 17
Accepted

Dependency #1:

100%
Accepted

Test #34:

score: 17
Accepted
time: 133ms
memory: 5720kb

input:

7545
31 1 1 4 1
15 1 8 13 1
34 1 12 18 1
9 1 1 9 1
28 1 5 12 1
21 1 1 11 1
33 1 9 11 1
28 1 10 14 1
33 1 30 30 1
33 1 19 31 1
31 1 2 25 1
24 1 13 18 1
22 1 11 16 1
33 1 20 20 1
28 1 7 8 1
31 1 5 28 1
30 1 17 18 1
22 1 3 9 1
12 1 6 12 1
30 1 7 21 1
31 1 3 10 1
34 1 24 27 1
35 1 21 26 1
26 1 7 13 1
31...

output:

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

result:

ok Correct (7545 test cases)

Test #35:

score: 17
Accepted
time: 114ms
memory: 5768kb

input:

1
200000 1 320 613 1

output:

NO

result:

ok Correct (1 test case)

Test #36:

score: 17
Accepted
time: 106ms
memory: 5708kb

input:

1
200000 1 37 328 1

output:

NO

result:

ok Correct (1 test case)

Test #37:

score: 17
Accepted
time: 119ms
memory: 5760kb

input:

1
200000 1 119733 157102 1

output:

NO

result:

ok Correct (1 test case)

Test #38:

score: 17
Accepted
time: 198ms
memory: 16328kb

input:

1
199920 1 392 510 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (1 test case)

Test #39:

score: 17
Accepted
time: 113ms
memory: 5816kb

input:

1
200000 1 201 860 1

output:

NO

result:

ok Correct (1 test case)

Test #40:

score: 17
Accepted
time: 113ms
memory: 6024kb

input:

1
200000 1 91 436 1

output:

NO

result:

ok Correct (1 test case)

Test #41:

score: 17
Accepted
time: 113ms
memory: 5856kb

input:

1
200000 1 82406 192973 1

output:

NO

result:

ok Correct (1 test case)

Test #42:

score: 17
Accepted
time: 190ms
memory: 16396kb

input:

1
199870 1 253 790 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (1 test case)

Test #43:

score: 17
Accepted
time: 198ms
memory: 14904kb

input:

2
171916 1 177 82364 1
28044 1 123 228 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (2 test cases)

Test #44:

score: 17
Accepted
time: 113ms
memory: 5760kb

input:

2
103116 1 240 317 1
96884 1 20 1362 1

output:

NO
NO

result:

ok Correct (2 test cases)

Test #45:

score: 17
Accepted
time: 186ms
memory: 15008kb

input:

2
23087 1 6 2290 1
176913 1 161 67795 1

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (2 test cases)

Test #46:

score: 17
Accepted
time: 188ms
memory: 13308kb

input:

2
143057 1 302 474 1
56943 1 23 28465 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (2 test cases)

Test #47:

score: 17
Accepted
time: 164ms
memory: 13004kb

input:

2
63028 1 16 184 1
136972 1 321 427 1

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (2 test cases)

Test #48:

score: 17
Accepted
time: 121ms
memory: 7496kb

input:

5
24325 1 20928 21374 1
33507 1 73 459 1
91848 1 195 471 1
16722 1 14075 15313 1
33554 1 111 177 1

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (5 test cases)

Test #49:

score: 17
Accepted
time: 134ms
memory: 7148kb

input:

5
86417 1 8 2042 1
570 1 1 570 1
32037 1 59 543 1
51708 1 51567 51694 1
29260 1 133 220 1

output:

NO
YES
570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 535 534 533 532 531 530 529 528 527 526 525 524 523 522 521 520 519 518 517 516 515 514 513 512 511 510 509 508 507 506 505 504 503 502 501 500 499 498 4...

result:

ok Correct (5 test cases)

Test #50:

score: 17
Accepted
time: 170ms
memory: 11388kb

input:

5
2977 1 53 241 1
3400 1 17 200 1
8955 1 84 106 1
110257 1 133 829 1
74252 1 38 1954 1

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (5 test cases)

Test #51:

score: 17
Accepted
time: 158ms
memory: 7808kb

input:

20
1300 1 1 23 1
2405 1 37 65 1
22960 1 40 574 1
15455 1 51 61 1
24568 1 11526 12902 1
322 1 12 25 1
4398 1 35 124 1
8257 1 14 28 1
10266 1 58 177 1
45942 1 93 494 1
1262 1 11 80 1
11310 1 87 130 1
12392 1 38 130 1
2809 1 6 468 1
2721 1 1282 2696 1
7236 1 27 268 1
5796 1 23 252 1
19372 1 14 16195 1
...

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (20 test cases)

Test #52:

score: 17
Accepted
time: 119ms
memory: 6028kb

input:

20
16303 1 37 322 1
4345 1 1949 3767 1
5808 1 11 528 1
5251 1 17 53 1
28284 1 44 404 1
35999 1 25775 29585 1
10283 1 7021 9568 1
5168 1 68 76 1
6800 1 12 344 1
5358 1 38 141 1
1027 1 12 35 1
47 1 3 15 1
11249 1 11 372 1
579 1 10 15 1
8741 1 62 6752 1
20511 1 22 711 1
8031 1 32 251 1
6585 1 2 1161 1
...

output:

NO
NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok Correct (20 test cases)

Test #53:

score: 17
Accepted
time: 140ms
memory: 5988kb

input:

100
1273 1 31 34 1
1503 1 10 151 1
2935 1 54 652 1
4872 1 28 174 1
2328 1 8 77 1
2048 1 20 41 1
4128 1 45 1456 1
2855 1 3 1169 1
6624 1 41 77 1
2447 1 1 2447 1
2266 1 21 31 1
1875 1 25 67 1
2960 1 17 174 1
2432 1 6 1932 1
8 1 2 6 1
516 1 9 11 1
127 1 7 18 1
5831 1 17 343 1
2060 1 1 27 1
1074 1 28 23...

output:

NO
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

ok Correct (100 test cases)

Test #54:

score: 17
Accepted
time: 139ms
memory: 5952kb

input:

1000
309 1 93 217 1
311 1 9 34 1
144 1 10 15 1
131 1 9 9 1
308 1 11 28 1
77 1 5 15 1
42 1 6 7 1
180 1 6 8 1
86 1 40 64 1
100 1 3 3 1
210 1 105 107 1
256 1 12 15 1
123 1 4 31 1
210 1 14 15 1
359 1 11 15 1
30 1 5 7 1
140 1 4 35 1
74 1 41 67 1
292 1 15 19 1
231 1 11 21 1
222 1 3 74 1
22 1 2 21 1
157 1 ...

output:

YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok Correct (1000 test cases)

Test #55:

score: 17
Accepted
time: 134ms
memory: 5688kb

input:

10000
12 1 3 4 1
2 1 1 1 1
43 1 2 11 1
5 1 3 3 1
19 1 3 4 1
20 1 6 14 1
15 1 2 6 1
2 1 2 2 1
68 1 7 10 1
9 1 1 6 1
6 1 1 4 1
40 1 2 2 1
6 1 2 2 1
40 1 3 13 1
12 1 2 5 1
21 1 2 8 1
38 1 1 38 1
26 1 1 26 1
1 1 1 1 1
18 1 1 14 1
59 1 17 56 1
16 1 1 4 1
12 1 9 9 1
2 1 1 1 1
12 1 2 6 1
1 1 1 1 1
2 1 1 1 ...

output:

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

result:

ok Correct (10000 test cases)

Test #56:

score: 17
Accepted
time: 136ms
memory: 5868kb

input:

20000
8 1 2 4 1
5 1 1 2 1
1 1 1 1 1
3 1 1 3 1
15 1 3 5 1
16 1 4 4 1
6 1 3 5 1
1 1 1 1 1
27 1 3 5 1
24 1 4 7 1
5 1 2 3 1
3 1 1 2 1
26 1 2 12 1
2 1 1 2 1
12 1 3 4 1
3 1 1 2 1
5 1 2 3 1
9 1 3 3 1
22 1 2 10 1
14 1 2 7 1
2 1 1 2 1
8 1 2 4 1
1 1 1 1 1
5 1 2 2 1
15 1 1 3 1
15 1 3 8 1
16 1 4 4 1
21 1 3 7 1
...

output:

YES
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
7 8 5 6 3 4 1 2
NO
YES
1
1
1
YES
3 2 1
1 2 3
1 2 3
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
13 14 15 10 11 12 7 8 9 4 5 6 1 2 3
YES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
13 14 15 16 9 10 11...

result:

ok Correct (20000 test cases)

Test #57:

score: 17
Accepted
time: 144ms
memory: 5772kb

input:

50000
2 1 1 2 1
3 1 1 3 1
5 1 1 2 1
1 1 1 1 1
5 1 2 2 1
2 1 1 2 1
2 1 1 2 1
2 1 1 1 1
2 1 1 1 1
6 1 1 5 1
4 1 1 4 1
3 1 1 3 1
4 1 2 2 1
1 1 1 1 1
2 1 1 2 1
2 1 1 2 1
3 1 1 3 1
3 1 1 3 1
2 1 1 2 1
10 1 1 10 1
1 1 1 1 1
1 1 1 1 1
6 1 1 1 1
1 1 1 1 1
6 1 2 4 1
1 1 1 1 1
5 1 2 2 1
14 1 2 8 1
1 1 1 1 1
6...

output:

YES
2 1
1 2
1 2
YES
3 2 1
1 2 3
1 2 3
NO
YES
1
1
1
NO
YES
2 1
1 2
1 2
YES
2 1
1 2
1 2
NO
NO
NO
YES
4 3 2 1
1 2 3 4
1 2 3 4
YES
3 2 1
1 2 3
1 2 3
YES
1 2 3 4
4 3 2 1
3 4 1 2
YES
1
1
1
YES
2 1
1 2
1 2
YES
2 1
1 2
1 2
YES
3 2 1
1 2 3
1 2 3
YES
3 2 1
1 2 3
1 2 3
YES
2 1
1 2
1 2
YES
10 9 8 7 6 5 4 3 2 1
...

result:

ok Correct (50000 test cases)

Subtask #5:

score: 0
Wrong Answer

Test #58:

score: 0
Wrong Answer
time: 122ms
memory: 5800kb

input:

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

output:

YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES...

result:

wrong answer Wrong answer (test case 1)

Subtask #6:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #86:

score: 0
Wrong Answer
time: 119ms
memory: 5832kb

input:

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

output:

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

result:

wrong answer Jury found the answer but participant didn't (test case 2)