QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87684#5742. Garbage DisposalNYCU_YamadaAC ✓23ms4184kbC++207.5kb2023-03-14 00:44:422023-03-14 00:44:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-14 00:44:45]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:4184kb
  • [2023-03-14 00:44:42]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int l, r;
    cin >> l >> r;
    if((r - l + 1) % 2 == 0) {
        vector<int> ans;
        for(int i = l; i <= r; ++i) 
            ans.eb(i);
        for(int i = 0; i <= r - l; i += 2) {
            swap(ans[i], ans[i + 1]);
        }
        for(int x : ans) {
            cout << x << ' ';
        }
        cout << '\n';
    }
    else {
        if(l == r) {
            cout << ((l == 1) ? 1 : -1) << '\n';
            return;
        }
        vector<int> ans;
        if(l & 1) {
            ans.eb(l + 1);
            ans.eb(l + 2);
            ans.eb(l + 0);
            for(int i = l + 3; i <= r; i += 2) {
                ans.eb(i + 1); ans.eb(i);
            }
            for(int x : ans) {
                cout << x << ' ';
            }
            cout << '\n';
        }
        else {
            cout << "-1\n";
        }
    }
}

int32_t main() {
    fastIO();
    
    int t = 1; cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define double __float80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
    static_assert(D >= 1, "Vector dimension must be greater than zero!");
    template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
};

template <typename T> struct Vec<1, T> : vector<T> {
    Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};

template <class F>
inline constexpr decltype(auto) lambda_fix(F&& f) {
    return [f = std::forward<F>(f)](auto&&... args) {
        return f(f, std::forward<decltype(args)>(args)...);
    };
}

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) {begin(_t);};

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() {cerr << "\n";};
template <typename T> inline void _do(T &&_t) {_print_err(_t), cerr << "\n";}
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) {_print_err(_t), cerr << ", ", _do(_u...);}
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) {cerr << _t;}

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3352kb

input:

3
1 5
10 13
100 100

output:

2 3 1 5 4 
11 10 13 12 
-1

result:

ok 3 cases (3 test cases)

Test #2:

score: 0
Accepted
time: 2ms
memory: 3360kb

input:

2
1 1
10 12

output:

1
-1

result:

ok 2 cases (2 test cases)

Test #3:

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

input:

2
9 13
3 9

output:

10 11 9 13 12 
4 5 3 7 6 9 8 

result:

ok 2 cases (2 test cases)

Test #4:

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

input:

1995
98 155
50 112
64 145
20 54
30 103
81 82
63 145
40 45
61 99
78 99
18 51
13 25
59 140
68 149
64 136
68 91
39 64
95 150
9 77
60 158
68 97
51 111
54 98
69 123
19 91
1 24
89 171
20 80
79 131
38 115
1 72
22 87
27 55
34 132
22 54
3 10
45 139
89 139
22 25
62 155
96 102
61 92
12 40
95 193
52 96
19 72
74...

output:

99 98 101 100 103 102 105 104 107 106 109 108 111 110 113 112 115 114 117 116 119 118 121 120 123 122 125 124 127 126 129 128 131 130 133 132 135 134 137 136 139 138 141 140 143 142 145 144 147 146 149 148 151 150 153 152 155 154 
-1
65 64 67 66 69 68 71 70 73 72 75 74 77 76 79 78 81 80 83 82 85 84 ...

result:

ok 1995 cases (1995 test cases)

Test #5:

score: 0
Accepted
time: 9ms
memory: 3460kb

input:

3904
968371485 968371509
701765963 701765970
549469142 549469161
619248225 619248243
427650297 427650314
881057515 881057554
339671073 339671118
868458958 868458991
114108035 114108078
452441415 452441459
293666096 293666097
947100230 947100278
884912210 884912225
655580789 655580816
741243970 74124...

output:

968371486 968371487 968371485 968371489 968371488 968371491 968371490 968371493 968371492 968371495 968371494 968371497 968371496 968371499 968371498 968371501 968371500 968371503 968371502 968371505 968371504 968371507 968371506 968371509 968371508 
701765964 701765963 701765966 701765965 701765968...

result:

ok 3904 cases (3904 test cases)

Test #6:

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

input:

18198
138241663 138241672
676972526 676972530
867876844 867876846
913955531 913955534
469993046 469993048
39688638 39688643
385261575 385261579
219784069 219784069
421044508 421044509
944566390 944566399
315592591 315592593
669733711 669733712
162886080 162886082
639609426 639609435
253660314 253660...

output:

138241664 138241663 138241666 138241665 138241668 138241667 138241670 138241669 138241672 138241671 
-1
-1
913955532 913955531 913955534 913955533 
-1
39688639 39688638 39688641 39688640 39688643 39688642 
385261576 385261577 385261575 385261579 385261578 
-1
421044509 421044508 
944566391 944566390...

result:

ok 18198 cases (18198 test cases)

Test #7:

score: 0
Accepted
time: 10ms
memory: 3420kb

input:

33298
777553849 777553849
334785771 334785773
573997215 573997216
138324260 138324264
802919250 802919253
965739697 965739697
791382357 791382357
510284693 510284693
7617431 7617434
344396965 344396966
776009722 776009725
934122341 934122342
456295677 456295677
637264010 637264014
915858631 91585863...

output:

-1
334785772 334785773 334785771 
573997216 573997215 
-1
802919251 802919250 802919253 802919252 
-1
-1
-1
7617432 7617431 7617434 7617433 
344396966 344396965 
776009723 776009722 776009725 776009724 
934122342 934122341 
-1
-1
915858632 915858633 915858631 915858635 915858634 
831424102 831424103...

result:

ok 33298 cases (33298 test cases)

Test #8:

score: 0
Accepted
time: 23ms
memory: 3476kb

input:

100000
450870929 450870929
501636706 501636706
821521310 821521310
505533172 505533172
86310682 86310682
271914160 271914160
87365014 87365014
346659996 346659996
96507146 96507146
359291557 359291557
278510610 278510610
34039227 34039227
247994589 247994589
620007867 620007867
13110207 13110207
403...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 cases (100000 test cases)

Test #9:

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

input:

7428
999999999 999999999
999999995 999999995
999999959 999999989
999999956 999999971
999999991 999999997
999999976 999999983
999999993 999999995
999999973 999999994
999999960 999999976
999999962 999999982
999999982 999999984
999999952 999999974
999999961 999999982
999999971 999999984
999999964 99999...

output:

-1
-1
999999960 999999961 999999959 999999963 999999962 999999965 999999964 999999967 999999966 999999969 999999968 999999971 999999970 999999973 999999972 999999975 999999974 999999977 999999976 999999979 999999978 999999981 999999980 999999983 999999982 999999985 999999984 999999987 999999986 9999...

result:

ok 7428 cases (7428 test cases)

Test #10:

score: 0
Accepted
time: 2ms
memory: 3500kb

input:

4
448340770 448421332
36161242 36163421
238130212 238145382
116964981 116966401

output:

-1
36161243 36161242 36161245 36161244 36161247 36161246 36161249 36161248 36161251 36161250 36161253 36161252 36161255 36161254 36161257 36161256 36161259 36161258 36161261 36161260 36161263 36161262 36161265 36161264 36161267 36161266 36161269 36161268 36161271 36161270 36161273 36161272 36161275 ...

result:

ok 4 cases (4 test cases)

Test #11:

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

input:

3
266069635 266148372
400267267 400268652
643992400 644010207

output:

266069636 266069635 266069638 266069637 266069640 266069639 266069642 266069641 266069644 266069643 266069646 266069645 266069648 266069647 266069650 266069649 266069652 266069651 266069654 266069653 266069656 266069655 266069658 266069657 266069660 266069659 266069662 266069661 266069664 266069663 ...

result:

ok 3 cases (3 test cases)

Test #12:

score: 0
Accepted
time: 10ms
memory: 4184kb

input:

1
196118330 196213437

output:

196118331 196118330 196118333 196118332 196118335 196118334 196118337 196118336 196118339 196118338 196118341 196118340 196118343 196118342 196118345 196118344 196118347 196118346 196118349 196118348 196118351 196118350 196118353 196118352 196118355 196118354 196118357 196118356 196118359 196118358 ...

result:

ok 1 cases (1 test case)

Test #13:

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

input:

1
194387582 194487581

output:

194387583 194387582 194387585 194387584 194387587 194387586 194387589 194387588 194387591 194387590 194387593 194387592 194387595 194387594 194387597 194387596 194387599 194387598 194387601 194387600 194387603 194387602 194387605 194387604 194387607 194387606 194387609 194387608 194387611 194387610 ...

result:

ok 1 cases (1 test case)

Test #14:

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

input:

1
79388006 79488005

output:

79388007 79388006 79388009 79388008 79388011 79388010 79388013 79388012 79388015 79388014 79388017 79388016 79388019 79388018 79388021 79388020 79388023 79388022 79388025 79388024 79388027 79388026 79388029 79388028 79388031 79388030 79388033 79388032 79388035 79388034 79388037 79388036 79388039 793...

result:

ok 1 cases (1 test case)

Test #15:

score: 0
Accepted
time: 6ms
memory: 4180kb

input:

1
621198489 621298488

output:

621198490 621198489 621198492 621198491 621198494 621198493 621198496 621198495 621198498 621198497 621198500 621198499 621198502 621198501 621198504 621198503 621198506 621198505 621198508 621198507 621198510 621198509 621198512 621198511 621198514 621198513 621198516 621198515 621198518 621198517 ...

result:

ok 1 cases (1 test case)