QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#288991#7861. Inverse Topological Sortucup-team112#AC ✓47ms9872kbC++2013.1kb2023-12-23 14:39:512024-11-22 19:53:05

Judging History

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

  • [2024-11-22 19:53:05]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:47ms
  • 内存:9872kb
  • [2024-11-22 19:52:53]
  • hack成功,自动添加数据
  • (/hack/1241)
  • [2023-12-23 14:39:52]
  • 评测
  • 测评结果:100
  • 用时:50ms
  • 内存:9672kb
  • [2023-12-23 14:39:51]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#ifndef RIN__LOCAL
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

template <typename T>
T sum(vector<T> &A) {
    T tot = 0;
    for (auto a : A) tot += a;
    return tot;
}

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
    cout << head;
    if (sizeof...(Tail)) cout << spa;
    print(std::forward<Tail>(tail)...);
}

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

template <class S, S (*op)(S, S), S (*e)()>
struct segtree {
  public:
    segtree() : segtree(0) {}
    explicit segtree(int n) : segtree(std::vector<S>(n, e())){};
    explicit segtree(const std::vector<S> &v) : _n(int(v.size())) {
        size = 1;
        log  = 0;
        while (size < _n) {
            log++;
            size <<= 1;
        }
        d = std::vector<S>(2 * size, e());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) update(i);
    }

    void set(int p, S x) {
        p += size;
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) {
        return d[p + size];
    }

    S prod(int l, int r) {
        S sml = e(), smr = e();

        l += size;
        r += size;

        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

  private:
    int _n, size, log;
    std::vector<S> d;
    void update(int k) {
        d[k] = op(d[2 * k], d[2 * k + 1]);
    }
};
struct S {
    int ind;
    int ma;
};
S op(S l, S r) {
    return l.ma > r.ma ? l : r;
}
S e() {
    return {-1, -1};
}

void solve() {
    LL(n);
    VEC(int, A, n);
    VEC(int, B, n);
    fori(i, n) {
        A[i]--;
        B[i]--;
    }

    using P = pair<int, int>;
    vec(P, edges, 0);

    {
        vec(int, inv, n);
        fori(i, n) inv[A[i]] = i;
        vec(int, bef, n, -1);
        stack<pair<int, int>> st;
        fori(i, n) {
            while (!st.empty() && st.top().first < A[i]) {
                st.pop();
            }
            if (!st.empty()) {
                bef[i] = st.top().second;
            }
            st.push({A[i], i});
        }

        segtree<S, op, e> seg(n);
        for (auto b : B) {
            int p = inv[b];
            seg.set(p, {p, 1});
            if (bef[p] == -1) continue;
            auto res = seg.prod(bef[p], p);
            if (res.ma == -1) {
                No();
                return;
            }
            edges.push_back({A[res.ind] + 1, A[p] + 1});
        }
    }

    {
        vec(int, inv, n);
        fori(i, n) inv[B[i]] = i;
        vec(int, bef, n, -1);
        stack<pair<int, int>> st;
        fori(i, n) {
            while (!st.empty() && st.top().first > B[i]) {
                st.pop();
            }
            if (!st.empty()) {
                bef[i] = st.top().second;
            }
            st.push({B[i], i});
        }

        segtree<S, op, e> seg(n);
        for (auto a : A) {
            int p = inv[a];
            seg.set(p, {p, 1});
            if (bef[p] == -1) continue;
            auto res = seg.prod(bef[p], p);
            if (res.ma == -1) {
                No();
                return;
            }
            edges.push_back({B[res.ind] + 1, B[p] + 1});
        }
    }

    Yes();
    print(len(edges));
    for (auto [u, v] : edges) {
        print(u, v);
    }

#ifdef RIN__LOCAL
    vec(int, AA, 0);
    vec(int, BB, 0);
    vec(int, in_, n, 0);
    vvec(int, E, n, 0);
    for (auto [u, v] : edges) {
        u--;
        v--;
        in_[v]++;
        E[u].push_back(v);
    }
    {
        auto I = in_;
        qp<int> hq;
        fori(i, n) {
            if (I[i] == 0) {
                hq.push(i);
            }
        }
        while (!hq.empty()) {
            int u = hq.top();
            hq.pop();
            AA.push_back(u);
            for (auto v : E[u]) {
                I[v]--;
                if (I[v] == 0) {
                    hq.push(v);
                }
            }
        }
    }
    {
        auto I = in_;
        pq<int> hq;
        fori(i, n) {
            if (I[i] == 0) {
                hq.push(i);
            }
        }
        while (!hq.empty()) {
            int u = hq.top();
            hq.pop();
            BB.push_back(u);
            for (auto v : E[u]) {
                I[v]--;
                if (I[v] == 0) {
                    hq.push(v);
                }
            }
        }
    }
    assert(AA == A);
    assert(BB == B);
#endif
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    // cout << fixed << setprecision(12);
    int t;
    t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

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

详细

Test #1:

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

input:

3
1 2 3
1 2 3

output:

Yes
2
1 2
2 3

result:

ok n=3

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

3
1 2 3
3 2 1

output:

Yes
0

result:

ok n=3

Test #3:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3
3 2 1
1 2 3

output:

No

result:

ok n=3

Test #4:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

10
6 8 9 4 1 3 7 5 10 2
8 6 9 10 4 7 5 3 2 1

output:

Yes
10
9 4
4 7
7 5
4 3
10 2
4 1
6 9
4 7
7 5
9 10

result:

ok n=10

Test #5:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

10
4 2 5 6 7 8 9 1 3 10
8 7 9 6 5 4 2 1 10 3

output:

Yes
6
4 2
9 1
1 3
7 9
1 3
1 10

result:

ok n=10

Test #6:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

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

output:

Yes
148
83 68
92 49
46 38
48 31
48 30
36 28
48 23
88 56
56 39
23 29
83 14
68 79
68 74
31 12
92 11
49 54
54 89
89 82
92 9
54 32
56 6
11 4
32 80
32 61
61 66
80 24
24 69
46 2
12 40
4 47
32 45
61 33
47 15
66 72
95 50
89 21
47 13
15 8
97 87
94 76
97 35
35 73
94 27
76 90
35 55
35 19
55 67
55 63
19 44
67 2...

result:

ok n=100

Test #7:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

1000
11 2 29 50 53 54 155 162 211 213 223 240 270 226 243 276 288 304 315 341 249 358 359 381 178 402 51 417 434 163 459 466 471 498 327 464 518 527 549 559 113 581 589 60 347 594 504 593 598 603 607 610 619 648 649 658 681 684 416 686 153 712 575 741 349 382 759 322 17 289 763 764 774 718 777 9 637...

output:

Yes
1830
998 857
777 637
859 605
594 593
594 504
741 382
684 416
498 327
759 322
998 296
296 813
813 585
857 891
322 289
938 431
431 746
808 437
270 226
226 243
327 464
995 374
374 800
741 349
381 178
924 835
434 163
585 830
849 806
830 520
800 458
891 912
999 509
509 743
341 249
605 194
431 709
709...

result:

ok n=1000

Test #8:

score: 0
Accepted
time: 33ms
memory: 9020kb

input:

100000
1 5 10 12 13 14 16 17 18 19 21 27 28 33 37 40 41 44 45 49 50 51 52 54 57 58 62 64 67 69 71 72 74 75 77 78 79 80 84 89 93 95 96 100 102 104 111 113 115 117 118 119 120 121 122 123 124 126 127 129 132 135 136 138 139 142 144 150 151 152 153 154 155 156 164 166 167 170 174 177 178 180 181 182 18...

output:

Yes
78810
98730 97977
98374 97491
97585 97439
97226 96905
99770 96516
99470 96456
99708 96045
98804 95984
99405 95807
99218 95786
95908 95597
98960 95432
96492 95287
96471 95235
98763 95220
95709 95195
97848 95062
99289 94764
96193 94712
99615 94620
98316 94615
96287 94539
98813 94532
99631 94457
98...

result:

ok n=100000

Test #9:

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

input:

100000
40 84 102 116 124 157 177 191 193 199 256 259 293 300 304 326 430 439 473 477 489 511 515 518 547 583 593 630 664 697 747 751 769 787 789 892 928 945 963 971 978 1052 1063 1067 1077 1080 1088 1101 1136 1143 1172 1180 1198 1274 1312 1359 1361 1380 1382 1404 1414 1428 1435 1466 1475 1497 1517 1...

output:

Yes
183695
99517 97606
99444 97229
99057 97122
98839 95491
96386 94750
99421 94466
91883 91234
92812 90920
97786 90810
98519 90778
98026 92847
91070 89637
97269 89481
89754 89438
91105 88865
97366 88561
94750 88547
92532 91454
99203 88387
94246 88344
89210 87936
98818 87794
96958 87747
95068 87574
9...

result:

ok n=100000

Test #10:

score: 0
Accepted
time: 16ms
memory: 7692kb

input:

100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 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...

output:

Yes
1988
98903 98445
99510 98320
98199 96547
98741 95536
98672 94928
99923 93649
96487 93632
94886 92588
96455 92584
98166 92297
95605 92074
96161 91990
95032 91295
93327 91017
95912 90458
95262 90237
98833 89806
89785 89700
96389 89518
97227 89478
99344 88821
99261 88410
97702 88357
98301 87653
935...

result:

ok n=100000

Test #11:

score: 0
Accepted
time: 35ms
memory: 9008kb

input:

100000
4 6 12 16 20 23 24 27 32 34 36 39 46 54 68 76 77 81 86 88 95 99 103 107 112 113 117 120 125 140 142 143 149 158 161 167 171 174 176 187 190 192 195 198 200 206 207 211 217 222 226 227 231 233 239 240 241 245 247 249 264 274 275 276 277 280 288 290 296 303 305 312 321 329 333 336 338 339 341 3...

output:

Yes
122343
99591 99531
99523 99446
99346 99101
99796 98421
98939 98388
99467 98361
98999 97628
98594 97426
97899 97156
98057 96511
99362 96372
99239 96343
96378 95924
95978 95854
98397 95779
98425 95759
98076 95696
98859 95422
98030 95246
98377 94928
99877 94877
98144 94835
97375 94799
99125 94766
9...

result:

ok n=100000

Test #12:

score: 0
Accepted
time: 20ms
memory: 8224kb

input:

100000
1 2 4 5 6 7 10 13 14 15 16 20 21 22 24 25 26 28 29 30 31 33 34 35 36 37 38 39 40 43 44 45 46 47 48 51 52 55 56 57 58 59 62 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 85 87 89 91 92 93 94 97 98 99 100 101 102 103 104 105 106 107 111 112 113 115 117 119 120 121 123 124 128 130 132 133 1...

output:

Yes
44465
99748 99700
99686 99130
99021 98841
99428 98548
99642 98445
99900 98273
98900 98271
99392 98031
98875 97921
98971 97290
97239 96760
99868 96631
98763 96512
99265 96384
99999 95873
97043 95799
97028 95723
95692 95432
97824 95396
96142 95375
96573 95338
95857 95322
97617 95146
97203 95046
97...

result:

ok n=100000

Test #13:

score: 0
Accepted
time: 47ms
memory: 9872kb

input:

100000
33 43 47 65 67 82 88 95 96 113 130 133 140 232 262 266 282 286 298 299 303 324 326 342 352 354 356 359 362 363 364 369 392 398 408 435 442 454 460 489 508 518 537 556 572 574 580 592 613 616 629 650 652 674 684 718 721 724 732 734 801 809 819 831 845 853 856 878 879 895 897 935 946 956 958 96...

output:

Yes
167027
98628 97971
98332 97401
98692 97147
97328 95884
98234 95724
99655 95400
98359 94839
97946 94762
98862 94190
93080 93041
99213 92910
93208 92686
95563 92251
99069 92222
96310 92120
92025 91944
96364 95767
92253 91785
97558 91622
91987 91370
98417 91235
94577 91213
97476 95775
90672 90023
9...

result:

ok n=100000

Test #14:

score: 0
Accepted
time: 46ms
memory: 9688kb

input:

100000
38535 3433 18670 53850 31420 79252 3155 90709 7043 47690 20905 66663 16655 77812 19606 78158 23549 54025 44700 24119 42542 85555 31117 68856 35627 37419 26767 46031 72252 71511 80835 47732 77030 61434 51792 98165 71334 70644 79996 87007 93335 56112 86306 3040 10776 30683 80961 96794 12323 656...

output:

Yes
199973
38535 3433
3433 18670
53850 31420
79252 3155
90709 7043
7043 47690
47690 20905
20905 66663
66663 16655
16655 77812
77812 19606
19606 78158
78158 23549
23549 54025
54025 44700
44700 24119
24119 42542
42542 85555
85555 31117
31117 68856
68856 35627
35627 37419
37419 26767
26767 46031
46031 ...

result:

ok n=100000

Test #15:

score: 0
Accepted
time: 11ms
memory: 7552kb

input:

100000
1 5 7 8 24 29 32 36 39 41 43 44 46 47 52 54 56 58 59 64 68 69 70 73 75 77 79 82 84 86 88 90 92 93 95 98 99 101 102 104 105 108 112 114 115 116 118 123 126 127 128 133 134 139 140 143 145 147 152 153 154 156 160 161 163 165 169 170 176 178 179 180 184 186 187 188 192 193 195 199 200 204 205 20...

output:

No

result:

ok n=100000

Test #16:

score: 0
Accepted
time: 7ms
memory: 7568kb

input:

100000
1 3 4 7 10 11 13 17 18 19 21 22 25 27 28 29 31 35 36 37 38 42 49 50 53 56 57 58 60 62 63 64 68 70 71 79 80 82 83 85 86 87 88 90 93 94 98 103 105 109 110 111 112 116 121 123 127 134 138 139 142 143 148 151 154 156 158 159 160 162 164 166 168 171 172 173 174 175 176 177 180 184 186 187 189 193 ...

output:

No

result:

ok n=100000

Test #17:

score: 0
Accepted
time: 8ms
memory: 7696kb

input:

100000
1 2 8 9 11 14 19 21 22 24 25 28 33 34 35 36 43 49 51 55 57 59 62 64 68 69 70 71 72 75 76 78 79 80 81 82 83 87 88 89 91 92 98 99 105 106 107 111 112 116 118 123 124 125 128 131 133 138 139 141 142 143 146 147 152 154 155 159 161 162 163 164 165 169 172 173 174 175 179 183 184 185 186 187 190 1...

output:

No

result:

ok n=100000

Test #18:

score: 0
Accepted
time: 8ms
memory: 7568kb

input:

100000
60 134 140 182 208 256 291 327 364 395 404 419 439 444 457 469 486 510 527 561 569 595 611 612 645 654 710 778 792 794 810 832 873 890 900 901 911 914 942 946 978 1022 1057 1060 1083 1094 1095 1146 1154 1155 1280 1323 1336 1368 1379 1388 1395 1480 1500 1509 1548 1573 1580 1597 1601 1622 1629 ...

output:

No

result:

ok n=100000

Test #19:

score: 0
Accepted
time: 8ms
memory: 7568kb

input:

100000
52072 2 3 50731 5 75525 49404 8 52753 2744 11 34189 13 48355 15 16 17 50376 86416 20 21 56114 23 20072 25 53838 48273 63338 29 30 60156 6205 8084 34 35 36 48381 71655 72484 63969 88506 59722 27083 5369 44672 86160 39926 48 49 8962 51 47113 53 69142 55 66271 24245 74454 59 72556 61 35930 86895...

output:

No

result:

ok n=100000

Test #20:

score: 0
Accepted
time: 8ms
memory: 7544kb

input:

100000
13821 33496 19412 85158 61916 61576 41795 39637 42402 12256 37931 7198 19499 24983 15918 19942 56948 7239 17886 24328 17628 63213 4681 90112 37749 17984 25778 75577 33274 43479 47779 64385 77793 82833 15116 96895 87829 30340 25506 7179 48585 77809 44101 91839 93597 69594 37840 3271 4541 68178...

output:

No

result:

ok n=100000

Test #21:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

1
1
1

output:

Yes
0

result:

ok n=1

Extra Test:

score: 0
Extra Test Passed