QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250660#1347. Universal and Existential QuantifiersIsaacMoris#WA 1ms3796kbC++141.7kb2023-11-13 15:19:092023-11-13 15:19:09

Judging History

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

  • [2023-11-13 15:19:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3796kb
  • [2023-11-13 15:19:09]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll solve1(vector<pair<ll, ll> > v, ll L) {
    ll last = -1, cnt = 0;
    ll max_r = -1;
    reverse(v.begin(), v.end());
    while (!v.empty() && max_r != L) {
        while (!v.empty() && v.back().first <= last + 1) {
            max_r = max(max_r, v.back().second);
            v.pop_back();
        }
        assert(max_r > last);
        last = max_r;
        cnt++;
    }

    return cnt;
}

void doWork() {
    ll n, L;
    cin >> n >> L;
    L--;
    vector<ll> values = {0, L};
    vector<pair<ll, ll> > v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        values.push_back(v[i].first);
        values.push_back(v[i].second - 1);
    }
    sort(values.begin(), values.end());
    values.resize(unique(values.begin(), values.end()) - values.begin());
    for (int i = 0; i < n; i++) {
        v[i].first = lower_bound(values.begin(), values.end(), v[i].first) - values.begin();
        v[i].second = lower_bound(values.begin(), values.end(), v[i].second - 1) - values.begin();
    }
    L = (int) values.size() - 1;

    sort(v.begin(), v.end());

    vector<int> freq(L + 2, 0);
    for (auto i: v) {
        freq[i.first]++;
        freq[i.second + 1]--;
    }
    ll ans = 0;

    for (int i = 0; i <= L; i++) {
        if (i)freq[i] += freq[i - 1];
        ans = max(ans, n - freq[i] + 1);
    }
    cout << solve1(v, L) << " " << ans;
}

int main() {
    IO
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

详细

Test #1:

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

input:

3 3
0 2
1 3
1 2

output:

2 3

result:

ok 2 number(s): "2 3"

Test #2:

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

input:

2 4
0 4
0 4

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

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

input:

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

output:

2 4

result:

ok 2 number(s): "2 4"

Test #4:

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

input:

72 6951
1279 5415
5774 5967
352 2975
4106 6269
565 3393
4119 5218
3154 4517
1323 4249
5468 6430
4356 6171
6461 6777
5997 6190
2895 6933
2072 5554
975 2873
3436 5916
6078 6377
6068 6569
4419 4775
4637 6656
1821 6617
2430 4645
4251 5125
2873 6894
5102 5914
785 2327
2853 6333
6091 6302
1477 6365
2015 4...

output:

3 72

result:

ok 2 number(s): "3 72"

Test #5:

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

input:

25 6007
2636 5976
4846 4848
2011 2320
4483 5650
4590 5525
5686 5983
4438 6007
3487 5407
5611 6005
5904 6006
4288 5436
3408 4233
2315 4762
5576 5660
3988 5327
956 5992
3368 5103
4448 5975
4629 4827
4557 5921
3696 6001
0 5196
2127 5131
4719 5451
793 5151

output:

2 25

result:

ok 2 number(s): "2 25"

Test #6:

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

input:

71 5875
3245 4539
2453 2646
5139 5424
4735 5233
0 5852
1073 1109
3220 4838
482 1667
4111 5874
1738 5508
1555 1757
5081 5369
2527 5054
321 4402
5183 5720
4395 4855
2774 5256
668 3284
4346 4564
2436 2932
1694 4462
1514 4716
2067 2165
5146 5349
869 4216
4850 5150
2636 5091
171 4352
1550 1830
4731 5286
...

output:

2 71

result:

ok 2 number(s): "2 71"

Test #7:

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

input:

72 3554
2007 2891
2321 3403
3423 3452
3513 3545
2651 2798
629 3542
3150 3310
2827 3181
550 3554
2884 3240
82 3553
1253 3467
66 1994
1871 2692
1730 2083
812 3547
863 1809
2622 2631
2883 3500
1543 2704
2225 3002
1057 2684
1562 3143
510 3532
1417 2880
3220 3337
2617 3222
2326 3092
2974 3124
509 3279
21...

output:

2 72

result:

ok 2 number(s): "2 72"

Test #8:

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

input:

12 2462
1212 2458
392 1970
710 1769
533 1677
1694 1742
2026 2462
0 1381
48 1400
1042 2460
1912 2330
293 2446
60 2293

output:

3 12

result:

ok 2 number(s): "3 12"

Test #9:

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

input:

11 8900
6913 8898
4203 8886
0 8147
5469 8883
7658 8900
8154 8876
3532 8701
4251 8869
7214 8843
8626 8899
3051 7676

output:

2 11

result:

ok 2 number(s): "2 11"

Test #10:

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

input:

54 8641
6433 7171
5844 5934
5405 7192
6544 6631
3012 5527
5374 6052
3439 6694
4120 4686
7324 8329
4422 8601
7053 8258
888 4474
972 1832
0 3047
3071 4758
5303 6898
7396 8394
5926 8602
3370 5206
1507 3332
7603 8141
3722 8387
4599 8637
292 5399
673 8640
2757 6991
68 1412
72 1074
4409 8210
4122 8039
161...

output:

3 54

result:

ok 2 number(s): "3 54"

Test #11:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

31 7482
1130 7210
4939 6328
0 66
28 89
1772 6450
3255 6386
1363 7482
5576 5931
1608 5509
4072 4513
1635 4691
5220 6904
5361 5915
5071 7474
5796 6472
1057 1989
20 1293
2983 5045
785 3917
4272 7470
2639 7473
2186 7468
1455 3299
373 1801
2715 6062
1972 5083
5290 6064
1288 1576
487 6403
4997 5897
3399 7...

output:

3 31

result:

wrong answer 1st numbers differ - expected: '4', found: '3'