QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#326626#1411. Communication Jammingtuanlinh1230 3ms14312kbC++203.5kb2024-02-13 16:50:212024-02-13 16:50:22

Judging History

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

  • [2024-02-13 16:50:22]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:14312kb
  • [2024-02-13 16:50:21]
  • 提交

answer

#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

const ll maxn=200005;
ll n, to[maxn], pa[maxn], Rank[maxn], l[maxn], r[maxn];
ll l1[maxn], r1[maxn], l2[maxn], r2[maxn];
ll X1[maxn], Y1[maxn], X2[maxn], Y2[maxn];
vector <ll> A1[maxn], A2[maxn], H1[maxn], H2[maxn]; 

ll Find(ll i)
{
    if (pa[i]!=i)
        pa[i]=Find(pa[i]);
    return pa[i];
}

void Union(ll a, ll b)
{
    ll Pa=Find(a), Pb=Find(b);
    if (Pa==Pb) return;
    if (Rank[Pa]<Rank[Pb]) swap(Pa, Pb);
    if (Rank[Pa]==Rank[Pb]) Rank[Pa]++;
    pa[Pb]=Pa, l[Pa]=min(l[Pa], l[Pb]), r[Pa]=max(r[Pa], r[Pb]);
}

void dfs1(ll u)
{
    l1[u]=n, r1[u]=0;
    for (ll v:A1[u])
    {
        if (!l1[v]) dfs1(v);
        l1[u]=min(l1[u], l1[v]), r1[u]=max(r1[u], r1[v]);
    }
}

void dfs2(ll u)
{
    l2[u]=n, r2[u]=0;
    for (ll v:A2[u])
    {
        if (!l2[v]) dfs2(v);
        l2[u]=min(l2[u], l2[v]), r2[u]=max(r2[u], r2[v]);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll m1, m2, q; cin >> n >> m1 >> m2 >> q;
    for (ll i=1; i<=n; i++)
        l1[i]=r1[i]=l2[i]=r2[i]=pa[i]=l[i]=r[i]=i;
    vector <ll> num1, num2; num2.pb(0);
    for (ll i=1; i<=m1; i++)
        cin >> X1[i] >> Y1[i], num1.pb(Y1[i]);
    sort(num1.begin(), num1.end());
    num1.resize(unique(num1.begin(), num1.end())-num1.begin());
    for (ll i=1; i<=m1; i++)
        H1[lower_bound(num1.begin(), num1.end(), Y1[i])-num1.begin()].pb(i+n);
    for (ll i=1; i<n+m1; i++)
    {
        ll t, u, v; cin >> t >> u >> v;
        if (t==1) A1[v+n].pb(u);
        else if (Y1[v]>Y1[u]) A1[v+n].pb(u+n);
        else A1[u+n].pb(v+n);
    }
    for (ll i=1; i<=m2; i++)
        cin >> X2[i] >> Y2[i], num2.pb(Y2[i]);
    sort(num2.begin(), num2.end(), greater<ll>());
    num2.resize(unique(num2.begin(), num2.end())-num2.begin());
    for (ll i=1; i<=m2; i++)
        H2[lower_bound(num2.begin(), num2.end(), Y2[i], greater<ll>())-num2.begin()].pb(i+n);
    for (ll i=1; i<n+m2; i++)
    {
        ll t, u, v; cin >> t >> u >> v;
        if (t==1) A2[v+n].pb(u);
        else if (Y2[v]<Y2[u]) A2[v+n].pb(u+n);
        else A2[u+n].pb(v+n);
    }
    for (ll i=1; i<=n+m1; i++)
        if (!l1[i]) dfs1(i);
    for (ll i=1; i<=n+m2; i++)
        if (!l2[i]) dfs2(i);
    auto in=[&](ll a, ll b) {return r[Find(a)]>=b;};
    auto insert=[&](ll a, ll b)
    {
        while (r[Find(a)]<b) 
            a=r[Find(a)]+1, Union(a, a-1);
    };
    ll k1=num1.size(), k2=num2.size();
    for (ll i=k1, ptr=0; i>=0; i--)
    {
        vector <pll> req;
        for (ll j:H1[i])
        {
            vector <pll> c;
            for (ll v:A1[j])
                if (r1[v]) c.pb({l1[v], r1[v]});
            sort(c.begin(), c.end());
            for (ll i=0; i+1<c.size(); i++)
                req.pb({c[i].se, c[i+1].fi});
        }
        for (auto [l, r]:req)
        {
            while (l<1 || r>n){}
            while (!in(l, r))
            {
                ptr++;
                for (ll j:H2[ptr]) 
                    if (r2[j])
                        insert(l2[j], r2[j]);
            }
        }
        to[i]=ptr;
    }
    for (ll i=1; i<=q; i++)
    {
        ll a; cin >> a;
        ll pos=upper_bound(num1.begin(), num1.end(), a)-num1.begin();
        cout << num2[to[pos]] << "\n";
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 0ms
memory: 13916kb

input:

100 99 99 100
40 71
79 29
1 20
88 54
70 38
77 30
31 12
79 81
84 34
17 65
68 57
40 2
14 22
56 3
15 17
11 75
36 77
52 7
30 91
82 13
19 64
44 14
63 41
38 18
99 84
22 49
68 39
64 63
99 93
8 48
66 10
6 83
45 35
94 37
58 87
89 15
71 4
75 60
59 42
74 62
56 59
82 73
90 24
76 95
36 21
91 67
33 31
13 79
20 50...

output:

-98
-98
-95
-95
-95
-99
-98
-98
-95
-98
-98
-99
-98
-98
-89
-95
-98
-98
-99
-98
-98
-95
-99
-95
-98
-95
-95
-95
-95
-95
-95
-95
-98
-98
-95
-99
-98
-98
-98
-99
-95
-98
-95
-98
-98
-98
-95
-95
-89
-98
-98
-95
-98
-95
-99
-99
-95
-99
-98
-98
-95
-98
-98
-95
-98
-98
-95
-98
-95
-99
-98
-95
-98
-95
-95
...

result:

ok 100 lines

Test #2:

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

input:

100 99 99 100
62 48
60 86
34 55
43 69
80 46
37 29
9 61
54 44
1 98
73 39
98 64
59 62
60 71
93 33
27 27
18 99
56 43
35 81
39 93
82 89
64 45
46 17
100 34
75 85
70 74
84 60
51 63
81 6
72 24
16 76
23 73
42 50
69 84
87 87
2 1
48 68
40 5
69 40
84 41
54 51
15 9
97 7
31 92
12 16
32 4
77 47
17 30
6 58
30 56
4...

output:

-97
-99
-99
-99
-97
-97
-99
-97
-97
-97
-97
-97
-97
-99
-99
-97
-97
-99
-99
-99
-97
-97
-97
-99
-99
-99
-97
-97
-97
-97
-97
-1
-97
-99
-97
-97
-97
-97
-97
-97
-99
-97
-97
-97
-99
-96
-99
-99
-96
-97
0
-97
-97
-97
-97
-97
-97
-38
-97
-97
-99
-97
-97
-99
-96
-97
-99
-97
-97
-97
-97
-99
-97
-99
-97
-97...

result:

ok 100 lines

Test #3:

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

input:

100 99 99 100
77 73
75 16
56 37
48 27
95 40
88 99
26 87
25 14
44 43
7 55
44 4
55 2
26 23
42 68
10 26
89 1
21 19
37 35
83 72
20 20
21 81
6 46
1 18
3 90
91 71
69 65
67 38
69 63
98 10
39 69
46 42
88 93
34 92
59 6
50 47
86 49
30 24
74 21
81 78
12 61
66 53
30 98
9 45
16 32
95 51
34 77
90 67
54 59
76 80
7...

output:

-99
-93
-99
-91
-99
-91
-99
-93
-93
-93
-93
-93
-99
-99
-99
-93
-93
-93
-99
-91
-91
-93
-93
-93
-99
-91
-99
-99
-93
-99
-91
-99
-93
-99
-99
-99
-99
0
-91
-93
-91
-93
-93
-99
-99
-99
-99
-99
-93
-99
-93
-99
-91
-93
-91
-91
-93
-91
-93
-93
-99
-93
-91
-99
-93
-91
-99
-99
-93
-93
-99
-91
-61
-93
-93
-9...

result:

ok 100 lines

Test #4:

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

input:

100 99 99 100
24 3
87 3
37 2
37 7
23 2
42 2
92 8
22 4
78 3
86 1
48 3
64 5
94 1
100 2
25 1
81 7
36 10
10 2
8 3
97 4
19 1
68 3
16 3
14 1
19 6
70 4
29 2
97 3
88 1
58 10
35 1
83 4
32 9
56 3
15 4
90 1
6 5
65 1
51 1
43 5
72 9
2 1
69 2
3 3
42 1
74 4
16 2
52 4
61 3
76 1
54 2
65 2
54 1
77 2
67 1
81 6
29 3
34...

output:

0
0
0
0
0
-7
0
0
0
0
-7
0
0
0
0
-9
0
0
0
0
0
0
0
-2
0
0
0
0
-10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-7
0
0
0
0
0
0
0
0
0
0
0
0
-7
-7
0
-9
0
0
0
0
0
-7
0
-10
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: 0
Accepted
time: 3ms
memory: 14116kb

input:

100 99 99 100
22 94
11 7
7 98
57 63
31 77
2 23
83 91
60 73
59 51
75 57
5 96
98 41
45 19
73 53
13 82
95 97
63 72
38 4
94 60
49 26
79 8
41 92
32 9
8 6
82 56
68 64
33 36
54 34
77 87
71 31
13 80
66 83
44 14
70 32
91 76
51 24
52 84
47 68
85 89
100 20
73 55
88 13
24 81
29 86
18 79
3 22
97 21
81 45
23 1
75...

output:

-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-3
-16
-3
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-3
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16...

result:

ok 100 lines

Test #6:

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

input:

100 99 99 100
50 1
18 1
34 3
24 3
6 2
42 4
14 5
69 1
65 4
36 1
19 3
36 6
73 2
53 1
41 1
32 2
6 1
75 1
45 2
27 1
14 1
15 4
82 2
64 1
10 1
76 3
50 3
19 1
12 3
39 1
60 2
98 2
71 5
55 6
97 1
40 3
38 5
46 1
51 5
2 1
57 3
62 2
35 1
96 3
88 7
60 13
59 1
26 2
91 10
12 4
91 1
62 1
17 2
77 6
66 1
21 14
84 1
2...

output:

0
0
-90
-90
0
0
0
0
0
0
0
0
0
0
0
0
0
-35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-90
0
0
0
0
0
-99
0
-90
0
0
0
-90
0
-99
-99
-99
0
0
0
0
0
0
0
0
0
-99
0
0
0
0
0
0
0
0
0
0
0
0
-30
-90
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-99
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #7:

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

input:

100 99 99 100
50 71
6 86
31 83
99 31
17 84
74 90
21 43
29 30
44 57
69 41
27 33
37 78
75 16
99 8
24 98
42 10
38 72
64 67
62 68
93 35
25 99
30 88
66 12
91 65
84 66
12 23
72 54
96 95
3 34
2 29
65 42
44 37
61 45
5 85
20 40
39 73
70 70
81 21
14 62
28 9
16 61
9 5
95 76
90 36
54 17
79 75
48 4
52 18
31 96
6...

output:

-51
-33
-88
-11
-96
-92
-53
-53
-41
-46
-17
-24
-44
-98
-1
-94
-41
-60
-91
-41
-99
-4
-48
-94
-66
-90
-72
-66
-32
-60
-60
-56
-10
-72
-78
-96
-50
-31
-23
-16
-37
-9
-20
-22
-45
-28
-74
-45
-86
-67
-82
-70
-50
-63
-76
-41
-6
-16
-41
-76
-34
-72
-88
-7
-35
-80
-7
-82
-26
-15
-31
-22
-47
0
-3
-28
-31
-...

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 3ms
memory: 13908kb

input:

100 99 99 100
94 28
42 79
56 77
38 8
32 9
2 19
77 84
84 16
16 47
43 2
53 89
89 71
13 63
3 18
85 97
5 96
70 72
48 66
10 88
7 49
40 81
57 43
95 61
66 45
61 11
67 24
43 92
32 34
59 26
16 22
35 74
50 38
17 67
63 76
19 4
62 42
53 64
35 33
21 86
93 37
46 12
48 39
8 98
25 85
2 50
88 32
12 48
25 41
95 54
91...

output:

-5
-37
-40
-88
-32
-27
-47
-86
-85
-99
-86
-70
-99
-31
-21
-96
-42
-66
-9
-41
-23
-22
-20
-74
-79
-60
-85
-20
-58
-56
-34
-63
-94
-16
-63
-33
-85
-59
-96
-75
-39
-68
-66
-85
-7
-68
-17
-53
-55
-85
-48
-94
-21
-7
-35
-47
-8
-22
-76
-26
-74
-15
-92
-91
-36
-40
-45
-56
-26
-70
-13
-44
-62
-91
-44
-28
-...

result:

ok 100 lines

Test #9:

score: 0
Accepted
time: 3ms
memory: 14116kb

input:

100 99 99 100
37 14
14 12
48 41
89 79
89 38
19 1
77 29
45 5
80 76
72 96
74 10
61 59
98 7
14 20
2 23
41 15
9 33
19 37
46 8
96 3
94 90
68 13
99 92
76 68
25 17
36 40
68 83
77 66
39 82
79 16
12 63
52 42
73 53
56 98
56 24
63 91
34 46
28 19
38 80
90 11
47 43
17 70
29 36
5 84
42 99
51 65
43 6
59 44
4 81
42...

output:

-40
-84
-87
-31
-53
-87
-38
-5
-36
-15
-84
-85
-58
-45
-85
-96
-10
-66
-81
-56
-15
-37
-68
-51
-75
-34
0
-3
-21
-99
-51
-54
-24
-73
-88
-7
-8
-62
-21
-10
-21
-96
-48
-42
-58
-15
-78
-31
-51
-44
-34
-99
-26
-97
-59
-56
-21
-90
-16
-1
-84
-25
-71
-73
-36
-11
-28
-95
-66
-47
-92
-31
-46
-15
-81
-74
-43...

result:

ok 100 lines

Test #10:

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

input:

100 99 99 100
76 93
59 12
54 11
40 74
73 43
48 47
38 31
95 78
65 37
28 44
96 17
35 13
90 85
86 65
81 4
88 79
71 64
47 15
41 63
52 46
32 90
42 73
16 9
62 10
87 94
97 70
2 99
42 21
6 5
21 6
58 58
56 76
100 69
46 83
12 42
31 75
74 14
97 24
37 50
9 35
5 8
22 84
69 39
30 49
54 52
77 51
27 38
94 45
25 16
...

output:

-38
-22
-40
-98
-25
-4
-46
-80
-43
-46
-77
-98
-4
-51
-82
-85
-7
-46
-35
-51
-75
-15
-77
-70
-90
-12
-55
-12
-59
-31
-55
-62
-88
-62
-9
-51
-7
-17
-86
-85
-59
-48
-28
-43
-92
-22
-19
-22
-46
-14
-12
-51
-27
-13
-35
-4
-90
-38
-19
-70
-19
-73
-65
-75
-64
-1
-75
-94
-85
-73
-32
-70
0
-80
-94
-27
-60
-...

result:

ok 100 lines

Test #11:

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

input:

1000 999 999 1000
29 797
230 668
310 981
2 879
197 826
352 362
407 805
890 87
249 584
295 199
531 588
687 528
433 565
288 46
385 474
431 86
639 686
942 656
388 667
310 282
737 578
161 430
823 664
333 979
989 745
46 432
999 236
962 545
949 655
902 406
812 521
632 812
715 47
313 691
840 665
294 336
72...

output:

-995
-999
-998
-999
-999
-999
-999
-999
-995
-999
-995
-999
-999
-999
-999
-998
-995
-995
-998
-995
-998
-999
-995
-995
-998
-995
-999
-995
-995
-998
-999
-999
-995
-998
-999
-999
-999
-999
-999
-999
-998
-999
-995
-998
-995
-998
-995
-995
-995
-999
-995
-999
-999
-995
-998
-995
-999
-995
-999
-999
...

result:

ok 1000 lines

Test #12:

score: -20
Wrong Answer
time: 3ms
memory: 14012kb

input:

1000 999 999 1000
113 7
720 15
233 4
882 1
419 1
818 2
746 2
168 1
682 3
470 5
927 11
673 3
945 1
178 6
25 3
460 2
26 7
709 1
746 1
563 6
309 3
280 2
774 2
657 2
133 5
512 1
394 1
634 4
175 6
720 7
272 12
825 1
287 2
787 1
327 2
978 7
705 1
758 6
716 1
101 1
46 3
273 1
545 1
62 9
316 7
247 2
917 1
7...

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
-25
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
-26
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-22
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:

wrong answer 55th lines differ - expected: '-12', found: '-25'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%