QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690077#5147. Stack SortIsacBieber#AC ✓19ms11360kbC++231.0kb2024-10-30 20:10:252024-10-30 20:10:26

Judging History

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

  • [2024-10-30 20:10:26]
  • 评测
  • 测评结果:AC
  • 用时:19ms
  • 内存:11360kb
  • [2024-10-30 20:10:25]
  • 提交

answer

#include <bits/stdc++.h>
// #include<bits/extc++.h>
#define endl '\n'
#define eps 1e-7
#define pb push_back
#define eb emplace_back
#define debug(x) cerr<<#x<<": "<<x<<'\n';
// using namespace __gnu_pbds;
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair <ll,ll>;
using pii = pair <int,int>;
using ull = unsigned long long;
const int N = 1e6 + 5, MOD = 1e9 + 7;
mt19937_64 rnd (chrono::steady_clock::now().time_since_epoch().count());
int n, a[N], p[N];
void isac()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i], p[a[i]] = i;
    int ans = 1;
    int idx = n + 1, need = 1;
    while(need<=n)
    {
        if(p[need]<idx) idx = p[need];
        else ans ++, idx = p[need];
        need ++;
    }
    cout<<ans<<'\n';
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) isac();
    return 0;
}
/*
    Zena youth together.
    Such a pretty name.
    There will be a long story.
    Time will tell all.
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3
1 2 3
3
3 2 1
5
1 4 2 5 3

output:

3
1
4

result:

ok 3 number(s): "3 1 4"

Test #2:

score: 0
Accepted
time: 19ms
memory: 5592kb

input:

100000
4
3 4 2 1
5
5 4 1 3 2
4
3 1 4 2
4
4 2 1 3
4
1 3 2 4
4
4 2 3 1
4
3 2 1 4
5
1 2 3 4 5
5
5 2 3 1 4
5
1 3 5 4 2
5
4 3 2 1 5
5
3 4 2 1 5
5
5 4 3 2 1
4
3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5
7
5
5
6
6
4
4
6
5
7
5
6
3
6
3
5
5
5
4
5
5
5
6
6
4
6
6
5
4
5
6
...

result:

ok 50000 numbers

Test #4:

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

input:

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

output:

48
48
50
49
43
48
47
42
42
47
42
49
50
47
43
44
53
49
46
46
51
53
51
55
55
45
47
47
46
50
47
48
48
48
52
46
49
50
51
49
48
50
51
43
53
45
50
46
46
45
47
49
51
48
50
49
44
49
53
45
45
48
48
48
49
47
44
44
51
45
50
49
50
45
48
49
48
51
47
49
53
47
49
44
48
48
44
50
47
50
51
44
53
42
52
55
50
49
47
48
...

result:

ok 5000 numbers

Test #5:

score: 0
Accepted
time: 17ms
memory: 5636kb

input:

500
959
670 618 579 212 780 557 380 412 672 951 777 921 684 768 99 952 140 122 139 919 623 17 911 18 880 790 625 505 307 747 801 754 783 146 757 263 285 228 719 640 199 193 105 234 847 842 348 159 823 577 466 954 850 851 643 802 819 317 826 55 617 690 604 229 570 254 759 575 498 240 397 736 864 415 ...

output:

473
472
468
454
477
480
484
457
472
443
469
507
483
476
493
495
491
481
500
480
514
447
484
483
453
468
444
456
474
468
501
485
461
499
458
483
506
516
475
464
446
465
475
475
446
457
500
493
478
481
451
452
473
464
442
505
493
483
486
448
499
464
477
483
507
491
442
490
480
492
492
472
473
459
464
...

result:

ok 500 numbers

Test #6:

score: 0
Accepted
time: 19ms
memory: 5796kb

input:

50
9597
2421 5801 7761 5556 4158 3033 4751 9284 3326 1858 2849 8472 5917 6077 4438 1948 5294 3028 4716 8042 2671 5305 5076 6924 5569 8173 6362 2160 3095 7385 1374 3167 8128 551 2363 1371 5799 3273 1366 5050 7680 198 5577 1236 2843 1127 5381 3029 6977 4823 702 8077 528 526 7027 4278 7947 6058 5005 90...

output:

4807
4635
4549
4566
4833
4548
4946
4695
4657
4745
4934
4675
4887
4802
4931
4559
4968
4688
4606
4637
4577
4629
4821
4505
4561
4844
4611
4688
4817
4967
4713
4824
4654
4523
4808
4964
4619
4788
4927
4630
4912
4842
4751
4529
4644
4623
4633
4518
4604
4914

result:

ok 50 numbers

Test #7:

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

input:

5
92316
4486 51971 40435 31486 22840 51804 19355 35116 71427 50525 34461 46690 44101 15605 33166 25846 90319 50846 8819 36285 58519 23478 20717 14434 37378 37454 60063 17182 70164 59883 45000 84942 58799 11505 13371 52739 66680 30438 67677 41266 53940 34428 79533 55092 76616 54423 21642 25614 48002 ...

output:

46162
50067
48874
46319
48245

result:

ok 5 number(s): "46162 50067 48874 46319 48245"

Test #8:

score: 0
Accepted
time: 19ms
memory: 9644kb

input:

1
471631
424496 112701 456051 347801 218724 312785 85999 325031 220919 219326 327801 239646 431816 121964 216653 223784 147176 29672 466026 412872 269415 238525 365823 442104 346534 297299 298496 242174 296754 297691 105566 80641 204310 21696 170588 199258 59123 336907 57422 387873 209433 272911 261...

output:

235867

result:

ok 1 number(s): "235867"

Test #9:

score: 0
Accepted
time: 19ms
memory: 9580kb

input:

1
488063
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...

output:

488063

result:

ok 1 number(s): "488063"

Test #10:

score: 0
Accepted
time: 19ms
memory: 11360kb

input:

1
471416
471416 471415 471414 471413 471412 471411 471410 471409 471408 471407 471406 471405 471404 471403 471402 471401 471400 471399 471398 471397 471396 471395 471394 471393 471392 471391 471390 471389 471388 471387 471386 471385 471384 471383 471382 471381 471380 471379 471378 471377 471376 4713...

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 13ms
memory: 5964kb

input:

10
48868
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...

output:

48868
46330
46349
49671
45183
48535
49233
49749
45094
46815

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 12ms
memory: 5884kb

input:

10
45668
45668 45667 45666 45665 45664 45663 45662 45661 45660 45659 45658 45657 45656 45655 45654 45653 45652 45651 45650 45649 45648 45647 45646 45645 45644 45643 45642 45641 45640 45639 45638 45637 45636 45635 45634 45633 45632 45631 45630 45629 45628 45627 45626 45625 45624 45623 45622 45621 456...

output:

1
1
1
1
1
1
1
1
1
1

result:

ok 10 numbers