QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882321#2787. Teamsthangthang0 3ms7464kbC++141.6kb2025-02-04 23:52:422025-02-04 23:52:42

Judging History

This is the latest submission verdict.

  • [2025-02-04 23:52:42]
  • Judged
  • Verdict: 0
  • Time: 3ms
  • Memory: 7464kb
  • [2025-02-04 23:52:42]
  • Submitted

answer

#ifdef ONLINE_JUDGE

#include "teams.h"

#endif // ONLINE_JUDGE

#include <bits/stdc++.h>

using namespace std;

const int MaxN = 1e5 + 5;

int n, a[MaxN], b[MaxN];
int q, m, k[MaxN], fl[MaxN], fr[MaxN];

void init(int N, int A[], int B[]){
    n = N;
    for (int i = 0; i < n; ++ i)
        fl[B[i]] ++, fr[A[i]] ++;

    for (int i = 1; i <= n; ++ i)
        fl[i] += fl[i - 1];

    for (int i = n; i >= 1; -- i)
        fr[i] += fr[i + 1];
}

int p[MaxN], s[MaxN];

int can(int M, int K[]){
    m = M;

    for (int i = M; i >= 1; -- i)
        s[i] = K[i - 1];

    s[0] = 0, s[m + 1] = 0;
    sort(s + 1, s + m + 1);
    vector <int> diff;
    for (int i = 1; i <= M; ++ i){
        p[i] = p[i - 1] + s[i];
        if (p[i] > n) return 0;

        if (s[i] != s[i - 1] || s[i] != s[i + 1])
            diff.push_back(i);
    }

    int sz = diff.size();
    for (int u = 0; u < sz; ++ u){
        int l = s[diff[u]];
        for (int v = u; v < sz; ++ v){
            int r = s[diff[v]];
            if (n - fl[l - 1] - fr[r + 1] < p[diff[v]] - p[diff[u] - 1])
                return 0;
        }
    }

    return 1;
}

#ifndef ONLINE_JUDGE

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; ++ i)
        cin >> a[i] >> b[i];

    init(n, a, b);

    cin >> q;
    for (int loops = 0; loops < q; ++ loops){
        cin >> m;
        for (int i = 0; i < m; ++ i)
            cin >> k[i];

        cout << can(m, k) << "\n";
    }
}

#endif // ONLINE_JUDGE

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 21
Accepted
time: 0ms
memory: 3712kb

input:

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

output:

1
0

result:

ok 2 lines

Test #2:

score: 21
Accepted
time: 0ms
memory: 5840kb

input:

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

output:

0

result:

ok single line: '0'

Test #3:

score: 21
Accepted
time: 1ms
memory: 5844kb

input:

100
3 61
37 63
52 79
42 87
5 38
13 33
56 95
53 95
69 96
23 51
30 87
31 79
2 58
41 95
13 89
51 86
5 46
71 81
3 7
21 91
23 90
11 85
50 88
31 77
26 27
31 91
23 66
32 48
22 79
36 81
42 46
33 76
67 79
41 48
15 42
4 51
21 90
51 92
60 90
31 78
21 93
62 94
88 98
25 79
23 59
27 52
46 85
12 43
15 28
20 96
24 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #4:

score: 21
Accepted
time: 0ms
memory: 3712kb

input:

100
47 100
59 68
22 81
26 31
23 59
13 98
24 28
37 63
15 72
60 74
7 89
62 94
1 60
30 87
71 81
6 29
13 89
52 79
36 53
69 77
2 58
3 61
34 48
21 91
39 47
43 85
21 90
31 50
36 81
13 28
33 76
5 77
24 85
28 59
29 57
53 95
12 43
51 92
7 20
15 28
3 7
17 47
78 90
49 94
67 76
60 82
46 85
41 48
32 48
20 46
20 9...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #5:

score: 21
Accepted
time: 1ms
memory: 5844kb

input:

100
31 79
43 85
5 38
78 90
31 78
92 97
13 98
36 81
17 47
23 59
56 95
25 79
9 66
24 61
88 98
33 76
4 51
50 88
22 79
14 66
7 20
94 98
15 72
24 85
29 57
7 89
41 95
5 6
36 53
51 86
6 29
21 93
31 50
60 90
53 95
26 31
3 7
46 60
58 62
32 48
51 77
24 28
46 85
23 66
21 91
11 85
85 93
31 77
67 79
13 28
2 58
5...

output:

1
0
1
1
1
1
1
0
1
1
0
1
1
0
0
1
0
1
1
1
1
1
0
0
0
1
1
1
0
1
1
1
0
1
1
0
0
1
0
1
1
1
1
1
1
1
0
0
0
1
0
1
0
1
0
0
0
0
1
1
1
0
1
1
0
1
1
1
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
0
1
0
0
0
0
1
1
1
0
0
1
1
0
0
1

result:

ok 100 lines

Test #6:

score: 21
Accepted
time: 1ms
memory: 3840kb

input:

100
69 77
71 81
5 6
60 90
11 85
31 50
52 79
67 79
22 82
60 74
94 98
15 28
24 61
15 42
60 82
9 62
26 31
7 20
31 79
12 43
24 85
3 7
7 89
51 77
69 96
62 94
17 47
22 79
28 59
50 88
34 48
85 93
42 46
2 58
37 63
47 100
22 81
5 77
42 87
14 66
23 51
41 95
51 86
37 84
33 76
20 46
1 60
31 91
41 48
36 81
61 64...

output:

0

result:

ok single line: '0'

Test #7:

score: 21
Accepted
time: 1ms
memory: 3712kb

input:

100
2 2
12 12
5 5
10 10
6 6
14 14
9 9
11 11
10 10
6 6
8 8
8 8
7 7
14 14
9 9
13 13
10 10
9 9
11 11
9 9
4 4
12 12
8 8
9 9
13 13
11 11
8 8
13 13
7 7
10 10
12 12
14 14
7 7
12 12
5 5
4 4
8 8
11 11
7 7
2 2
9 9
5 5
13 13
13 13
12 12
9 9
3 3
8 8
12 12
6 6
11 11
10 10
13 13
1 1
13 13
13 13
10 10
12 12
7 7
13...

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 100 lines

Test #8:

score: 21
Accepted
time: 1ms
memory: 3712kb

input:

100
14 14
10 10
14 14
13 13
13 13
10 10
12 12
11 11
12 12
13 13
14 14
3 3
10 10
4 4
13 13
5 5
7 7
11 11
6 6
9 9
14 14
9 9
10 10
6 6
13 13
5 5
14 14
13 13
14 14
12 12
11 11
10 10
12 12
11 11
13 13
9 9
13 13
1 1
7 7
12 12
6 6
10 10
8 8
11 11
8 8
6 6
12 12
12 12
8 8
9 9
14 14
4 4
11 11
6 6
10 10
12 12
...

output:

1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
1
0
0
0
0
1
0
1
0
1
1
1
0
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
1
0
1

result:

ok 100 lines

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 5840kb

input:

100
7 7
8 8
11 11
14 14
13 13
14 14
10 10
12 12
12 12
6 6
9 9
10 10
13 13
12 12
1 3
12 12
5 5
8 8
12 12
10 10
11 11
12 12
14 14
9 9
13 13
6 6
5 5
10 10
12 12
2 2
9 9
10 10
2 2
13 13
11 11
10 10
7 7
12 12
9 9
7 7
12 12
6 6
13 13
8 8
13 13
7 7
13 13
9 9
1 3
10 10
13 13
13 13
12 12
14 14
9 9
11 11
6 6
...

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:

wrong answer 1st lines differ - expected: '0', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #27:

score: 13
Accepted
time: 1ms
memory: 6588kb

input:

100000
46503 61502
34278 63026
24651 60296
27921 32693
40654 78541
38357 97853
50234 74256
28875 64172
1156 66821
33682 85011
38633 55442
26468 75403
7744 95912
7639 20373
3489 65670
44385 68195
80744 92399
443 48207
20978 48590
42574 66994
94782 98699
69048 75985
3748 51039
56069 88210
15619 22502
...

output:

0

result:

ok single line: '0'

Test #28:

score: 13
Accepted
time: 1ms
memory: 5248kb

input:

100000
23870 62096
6565 45612
1109 94686
60692 94017
34512 95079
64450 77378
21832 56221
45089 57006
46643 50408
96079 97119
60110 82767
11385 91389
34321 46387
53829 66069
14404 75150
6213 57606
43918 82140
4948 55435
23376 51028
22205 30478
29042 31756
31998 33180
41368 57346
52764 68043
11566 707...

output:

0

result:

ok single line: '0'

Test #29:

score: 13
Accepted
time: 3ms
memory: 5248kb

input:

100000
59419 71286
61502 99530
19798 67560
47714 64697
63194 78267
31804 43941
85524 99088
15970 21868
15988 90245
63235 72884
63991 89776
41084 64662
16736 30436
38234 67822
6618 77375
24943 64281
54442 81083
68112 82304
24706 89837
23429 56940
67196 81327
7563 54090
44866 92572
42558 53589
7177 12...

output:

0

result:

ok single line: '0'

Test #30:

score: 13
Accepted
time: 3ms
memory: 7464kb

input:

100000
1944 80185
69187 72472
34047 96645
10337 26581
37740 38042
86446 89641
8612 40278
58479 86291
603 66823
24457 68474
32273 58099
66226 82969
48942 92984
10992 85845
12327 80011
51720 65232
9785 60095
42330 61984
64948 97483
2241 27315
17115 18722
70340 71532
15354 85275
7477 32850
52595 91322
...

output:

0

result:

ok single line: '0'

Test #31:

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

input:

100000
150 150
381 381
205 205
56 56
300 300
420 420
324 324
354 354
286 286
445 445
204 204
291 291
135 135
444 444
266 266
371 371
302 302
112 112
198 198
345 345
264 264
301 301
286 286
379 379
237 237
273 273
381 381
294 294
434 434
387 387
267 267
253 253
425 425
442 442
349 349
302 302
377 377...

output:

1

result:

ok single line: '1'

Test #32:

score: 13
Accepted
time: 3ms
memory: 5248kb

input:

100000
189 189
279 279
274 274
318 318
366 366
148 148
403 403
331 331
182 182
163 163
416 416
103 103
415 415
146 146
243 243
403 403
166 166
440 440
285 285
410 410
433 433
341 341
47 47
312 312
141 141
114 114
432 432
319 319
225 225
417 417
290 290
377 377
439 439
140 140
154 154
374 374
447 447...

output:

0

result:

ok single line: '0'

Test #33:

score: 0
Wrong Answer
time: 3ms
memory: 5376kb

input:

100000
306 306
407 407
371 371
329 329
386 386
426 426
306 306
289 289
432 432
422 422
251 251
222 222
245 245
351 351
245 245
329 329
310 310
447 447
354 354
193 193
254 254
185 185
447 447
213 213
352 352
300 300
300 300
360 360
251 251
406 406
290 290
424 424
392 392
366 366
240 240
408 408
82 82...

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%