QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120010#5742. Garbage Disposalhos_lyricAC ✓15ms3704kbC++142.1kb2023-07-06 10:56:262023-07-06 10:56:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 10:56:28]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3704kb
  • [2023-07-06 10:56:26]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


int L, R;

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d%d", &L, &R);
    ++R;
    
    vector<int> ans(R - L, 0);
    if (R - L == 1) {
      if (L == 1) {
        ans[0] = L;
      } else {
        ans = {};
      }
    } else if ((R - L) % 2 != 0) {
      if (L % 2 != 0) {
        // [odd, odd]
        ans[0] = L + 2;
        ans[1] = L + 0;
        ans[2] = L + 1;
        for (int i = 3; i < R - L; ++i) {
          ans[i] = L + 3 + ((i - 3) ^ 1);
        }
      } else {
        // [even, even]
        ans = {};
      }
    } else {
      for (int i = 0; i < R - L; ++i) {
        ans[i] = L + (i ^ 1);
      }
    }
    
    if (!ans.empty()) {
      for (int i = 0; i < R - L; ++i) {
        if (i) printf(" ");
        printf("%d", ans[i]);
      }
      puts("");
    } else {
      puts("-1");
    }
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

3
1 5
10 13
100 100

output:

3 1 2 5 4
11 10 13 12
-1

result:

ok 3 cases (3 test cases)

Test #2:

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

input:

2
1 1
10 12

output:

1
-1

result:

ok 2 cases (2 test cases)

Test #3:

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

input:

2
9 13
3 9

output:

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

result:

ok 2 cases (2 test cases)

Test #4:

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

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 8...

result:

ok 1995 cases (1995 test cases)

Test #5:

score: 0
Accepted
time: 4ms
memory: 3628kb

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:

968371487 968371485 968371486 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: 12ms
memory: 3632kb

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
385261577 385261575 385261576 385261579 385261578
-1
421044509 421044508
944566391 944566390 9445...

result:

ok 18198 cases (18198 test cases)

Test #7:

score: 0
Accepted
time: 15ms
memory: 3680kb

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
334785773 334785771 334785772
573997216 573997215
-1
802919251 802919250 802919253 802919252
-1
-1
-1
7617432 7617431 7617434 7617433
344396966 344396965
776009723 776009722 776009725 776009724
934122342 934122341
-1
-1
915858633 915858631 915858632 915858635 915858634
831424103 831424101 8314241...

result:

ok 33298 cases (33298 test cases)

Test #8:

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

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: 9ms
memory: 3612kb

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
999999961 999999959 999999960 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: 1ms
memory: 3688kb

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: 10ms
memory: 3704kb

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: 3ms
memory: 3640kb

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: 10ms
memory: 3632kb

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: 9ms
memory: 3632kb

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: 10ms
memory: 3636kb

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)