QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783218#6260. Historic Exhibition353cerega#AC ✓3ms3940kbC++141.4kb2024-11-26 01:40:442024-11-26 01:40:45

Judging History

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

  • [2024-11-26 01:40:45]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3940kb
  • [2024-11-26 01:40:44]
  • 提交

answer

#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define X first
#define Y second


const ll mod = 1000000007;
//const ll mod = 998244353;



ll pew(ll a, ll b) {
    ll res = 1;
    while (b>0) {
        if (b&1) res = res*a%mod;
        b >>= 1;
        a = a*a%mod;
    }
    return res;
}



void solve() {
    ll n, m;
    cin >> n >> m;
    vector<pair<pair<ll,ll>,ll>> a(n);
    for (ll i=0;i<n;i++) {
        cin >> a[i].X.X >> a[i].X.Y;
        a[i].Y = i;
        if (a[i].X.X>a[i].X.Y) swap(a[i].X.X,a[i].X.Y);
    }
    sort(a.begin(),a.end());
    vector<pair<ll,ll>> b(m);
    for (ll i=0;i<m;i++) {
        cin >> b[i].X;
        b[i].Y = i;
    }
    sort(b.begin(),b.end());
    vector<ll> ans(m);
    for (ll i=0,j=0;i<m;i++) {
        while (j<n and a[j].X.X!=b[i].X and a[j].X.Y!=b[i].X) {
            j++;
        }
        if (j==n) {
            cout << "impossible\n";
            return;
        }
        ans[b[i].Y] = a[j].Y;
        j++;
    }
    for (int i=0;i<m;i++) cout << ans[i]+1 << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

1
4
3

result:

ok correct

Test #2:

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

input:

2 2
1 1
2 3
1 1

output:

impossible

result:

ok impossible

Test #3:

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

input:

2 3
9 8
4 5
4 9 5

output:

impossible

result:

ok impossible

Test #4:

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

input:

1000 1000
141 140
239 240
380 380
114 115
345 345
60 60
341 340
224 223
400 399
125 124
163 162
53 53
62 62
326 326
36 36
91 92
187 186
48 49
123 123
232 233
275 274
374 373
321 322
251 250
347 348
221 222
64 65
143 144
65 65
135 136
209 208
336 336
118 117
189 190
87 86
58 58
66 67
185 185
289 288
...

output:

637
617
757
377
1
201
955
432
896
680
959
718
545
70
750
454
898
535
84
985
715
745
421
340
39
936
103
562
487
710
343
293
909
628
154
390
145
339
326
597
918
313
486
725
129
986
12
412
257
647
250
220
445
624
245
22
493
21
27
491
283
667
265
152
859
515
321
110
586
51
588
559
381
77
536
729
286
462...

result:

ok correct

Test #5:

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

input:

100 100
9 9
3 3
9 9
5 4
8 7
19 20
8 8
10 11
19 18
18 18
8 9
20 20
15 14
8 9
16 15
8 7
8 9
7 8
7 8
2 3
5 6
12 13
8 7
14 13
13 13
8 9
3 2
16 15
17 18
15 14
18 19
6 6
14 14
4 3
17 18
16 16
4 3
9 10
3 2
8 8
12 11
4 5
8 8
5 4
5 6
6 5
14 13
9 10
1 2
12 12
19 18
19 18
12 13
11 12
1 1
9 8
8 8
4 3
1 2
3 4
7 ...

output:

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

result:

ok correct

Test #6:

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

input:

100 60
11 11
43 44
15 16
27 27
18 18
8 8
2 1
58 57
23 22
10 11
14 15
9 8
37 38
57 56
32 33
48 49
23 22
13 12
6 5
28 29
4 4
4 3
6 7
14 15
6 7
42 42
5 5
2 2
48 48
2 1
18 17
49 48
15 16
8 7
38 38
35 34
33 32
38 39
36 35
41 40
18 19
7 7
45 44
53 52
11 11
26 25
15 14
35 36
5 4
7 8
56 55
19 18
52 52
35 35...

output:

40
34
30
29
31
3
11
12
70
23
2
16
8
36
19
13
65
22
28
58
61
24
15
38
89
39
18
60
26
43
68
4
47
20
35
98
95
88
7
32
97
10
59
83
100
5
73
57
63
9
25
90
46
62
17
51
96
66
64
53

result:

ok correct

Test #7:

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

input:

10 7
3 4
1 1
4 4
4 5
2 3
6 6
3 2
1 2
4 3
3 4
2 1 5 4 4 3 2

output:

8
2
4
1
9
7
5

result:

ok correct

Test #8:

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

input:

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

output:

1
4
2

result:

ok correct

Test #9:

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

input:

10000 10000
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
...

output:

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
101
102
...

result:

ok correct

Test #10:

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

input:

10000 10000
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
...

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

impossible

result:

ok impossible

Test #12:

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

input:

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

output:

1
2
3
4

result:

ok correct

Test #13:

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

input:

7 8
2 1
3 2
2 3
5 4
7 6
7 6
8 7
1 2 3 4 5 6 7 8

output:

impossible

result:

ok impossible

Test #14:

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

input:

0 0


output:


result:

ok correct

Test #15:

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

input:

1 0
1 1


output:


result:

ok correct

Test #16:

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

input:

0 1
1

output:

impossible

result:

ok impossible

Test #17:

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

input:

2 0
1 2
2 1


output:


result:

ok correct

Test #18:

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

input:

1 1
2 2
1

output:

impossible

result:

ok impossible

Test #19:

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

input:

12 10
1 2
1 2
2 3
2 3
2 3
2 3
3 3
3 3
3 4
4 5
8 9
8 9
1 1 3 3 3 3 3 3 3 4

output:

1
2
3
4
5
6
7
8
9
10

result:

ok correct

Test #20:

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

input:

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

output:

4
1
2

result:

ok correct

Test #21:

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

input:

3 2
1 1
1 1
1 1
1 1

output:

1
2

result:

ok correct

Test #22:

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

input:

8 8
2 1
3 2
2 3
5 4
5 4
7 6
7 6
8 7
1 2 3 4 5 6 7 8

output:

1
2
3
4
5
6
7
8

result:

ok correct

Test #23:

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

input:

10 5
1824 1825
411 410
4507 4508
4012 4013
3657 3658
3813 3812
9196 9195
3612 3612
107 106
5575 5575
1825 410 4507 4013 3658

output:

1
2
3
4
5

result:

ok correct

Test #24:

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

input:

7907 7305
1614 1614
1911 1912
7213 7213
5742 5742
1445 1446
913 914
5419 5419
8198 8197
4726 4726
1495 1496
908 909
9658 9658
6650 6649
8026 8025
7172 7172
7549 7550
5784 5785
9924 9925
3150 3149
204 204
6536 6537
2009 2008
5111 5112
9724 9723
4407 4407
9448 9448
504 504
2035 2036
808 808
6533 6534
...

output:

impossible

result:

ok impossible

Test #25:

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

input:

5849 2078
1 2
9 10
5 4
4 3
6 6
2 2
10 9
7 6
1 2
7 7
6 7
3 3
5 6
3 2
6 5
4 4
10 9
4 4
5 6
9 9
8 9
8 8
8 9
1 1
5 6
5 6
6 7
3 3
3 3
7 8
1 1
1 1
10 9
9 8
10 10
2 2
5 5
3 4
5 5
10 10
6 5
8 9
8 9
5 4
10 9
5 4
7 8
4 5
3 3
1 1
4 3
10 10
1 2
2 1
8 9
10 10
8 9
8 8
6 5
5 5
5 6
4 4
8 8
3 3
3 3
9 10
9 10
8 8
3 4...

output:

30
4
38
14
81
24
51
31
13
21
93
69
47
1
15
32
23
2
50
77
97
3
44
108
8
34
82
109
141
142
90
7
17
46
105
11
19
33
95
42
123
45
130
48
9
112
102
43
66
168
55
67
189
71
25
57
118
79
144
76
164
53
104
208
26
219
252
253
27
85
124
41
185
89
264
196
212
88
271
113
256
170
177
54
96
186
162
171
103
270
115...

result:

ok correct

Test #26:

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

input:

6860 65
4385 4384
6177 6177
2840 2841
9943 9943
7434 7434
3062 3062
6494 6495
2996 2997
398 398
3079 3078
9199 9198
6932 6931
5376 5376
1247 1247
6853 6854
8779 8780
3534 3533
2548 2547
5477 5477
7404 7404
1603 1603
8023 8023
1990 1991
1776 1776
9769 9768
8250 8250
6182 6181
6496 6497
1046 1045
3839...

output:

impossible

result:

ok impossible

Test #27:

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

input:

2307 1314
7 6
7 7
3 4
6 5
1 1
6 7
4 5
5 4
4 3
8 8
8 7
9 10
9 8
2 1
7 6
9 9
2 3
7 6
6 6
6 6
7 7
6 5
8 9
3 3
7 7
10 10
4 3
9 9
2 3
9 10
3 3
5 4
6 7
4 4
1 1
4 4
2 1
1 2
7 8
9 10
5 5
9 9
8 7
1 2
8 8
1 2
4 4
9 8
3 2
9 8
10 10
4 3
5 5
9 8
6 6
6 7
7 7
3 4
3 2
7 8
10 10
3 4
8 8
4 3
8 7
1 2
2 3
10 9
6 7
1 2
...

output:

1
3
12
11
39
13
5
4
7
198
17
8
43
9
6
22
203
35
15
18
33
79
102
23
95
48
60
27
107
52
29
101
204
50
113
230
49
254
279
32
117
288
59
65
56
30
307
77
330
124
86
69
40
67
96
75
54
354
110
58
84
82
164
165
174
359
68
62
87
147
115
85
207
83
103
149
64
154
90
130
140
126
72
91
97
188
118
98
199
111
222
...

result:

ok correct

Test #28:

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

input:

7314 4728
6 7
10 9
5 6
6 7
10 10
1 2
8 9
7 7
5 6
1 2
3 2
2 2
3 3
6 6
6 5
7 6
5 5
7 6
9 10
4 5
9 8
9 9
10 9
7 7
9 10
1 2
8 7
3 4
1 2
5 5
3 3
8 8
6 5
3 3
1 2
1 1
2 3
9 10
7 8
2 1
10 9
6 5
9 8
7 8
8 8
7 7
1 2
3 2
7 6
9 10
4 3
5 6
9 10
8 7
1 2
10 9
10 9
3 4
1 2
5 6
4 5
8 7
8 7
3 4
3 4
8 7
3 2
1 1
8 7
4 ...

output:

20
11
27
36
2
61
28
1149
70
68
1
72
51
1156
1183
39
1188
7
44
21
19
54
4
43
1213
23
25
37
1219
38
73
41
83
75
62
58
16
50
1221
88
81
18
107
1223
63
86
3
49
128
66
69
53
1227
136
103
112
115
56
120
9
48
141
134
176
64
74
140
57
15
92
94
33
164
142
1244
95
65
129
132
139
145
163
80
99
93
111
100
178
1...

result:

ok correct

Test #29:

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

input:

9031 3313
1 1
8 7
2 2
1 1
1 1
7 7
10 10
4 5
3 3
4 5
2 1
6 6
2 1
7 7
5 6
6 6
2 2
5 5
5 5
5 4
7 7
8 8
2 3
7 7
9 9
1 2
4 3
1 2
7 6
5 4
2 2
7 7
2 3
8 8
5 4
4 5
5 6
8 9
6 6
4 3
2 1
7 7
2 1
4 4
1 1
2 3
4 4
5 6
3 2
1 2
6 7
3 2
8 9
9 8
8 8
3 4
7 7
8 8
3 2
5 5
2 3
1 2
4 4
6 7
9 9
4 3
4 4
6 7
2 2
2 1
4 5
10 1...

output:

29
38
53
81
1
51
2
11
13
4
15
27
5
8
45
156
26
28
54
10
100
88
64
68
41
43
106
40
76
20
83
165
50
37
56
170
62
30
48
99
66
104
118
110
105
96
77
82
35
70
119
144
78
75
182
194
92
124
97
125
140
23
169
133
98
101
36
33
212
112
171
90
253
164
114
113
126
207
180
46
166
123
208
175
260
143
262
49
155
7...

result:

ok correct

Test #30:

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

input:

4282 507
5 5
7 6
4 3
7 8
1 1
2 1
10 10
10 10
7 6
3 2
6 7
7 8
1 1
4 4
6 5
10 10
5 4
3 4
9 8
3 3
6 5
1 1
6 7
2 2
10 10
5 5
6 7
4 5
9 9
1 2
8 7
3 3
6 7
3 2
1 1
5 4
7 8
4 4
6 5
6 6
7 7
10 10
1 1
7 8
8 9
3 3
3 4
6 7
3 3
10 9
6 6
2 2
2 2
2 1
10 10
2 2
3 4
10 9
10 9
4 5
3 4
4 5
2 3
7 8
2 2
2 1
5 4
2 1
3 2
...

output:

15
17
2
9
4
10
12
6
3
28
50
31
30
37
19
18
5
21
54
45
34
44
11
100
13
63
23
39
27
36
47
58
109
33
60
64
115
57
48
61
84
66
71
81
59
74
69
86
106
108
116
68
70
73
113
82
93
129
111
124
107
152
62
146
118
148
156
159
127
76
136
171
145
153
22
139
35
140
83
161
43
162
99
157
149
126
142
169
179
176
67
...

result:

ok correct

Test #31:

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

input:

5976 8723
5 6
10 10
7 7
5 6
9 8
7 8
10 10
9 10
3 4
3 4
7 6
2 2
7 8
9 8
4 5
10 9
10 10
9 9
7 6
4 5
4 3
9 9
9 9
7 8
3 2
8 9
4 5
7 8
7 8
6 5
5 4
2 2
10 10
5 6
5 6
3 4
1 1
7 8
3 2
6 5
8 7
5 5
7 8
3 2
2 3
1 2
2 3
6 7
9 10
2 3
6 6
8 8
2 1
1 2
3 4
8 7
10 9
1 1
5 5
2 2
3 3
4 5
3 4
9 8
1 2
8 8
5 6
3 3
5 4
8 ...

output:

impossible

result:

ok impossible

Test #32:

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

input:

7389 5821
1 2
6 5
10 9
9 10
10 9
3 3
8 8
1 1
3 4
8 7
1 2
9 8
4 4
10 9
10 9
9 10
5 4
10 10
6 7
9 10
8 9
2 3
7 6
7 7
10 9
3 2
10 10
7 6
6 6
2 2
6 6
3 2
9 8
4 3
3 4
4 5
10 10
8 8
1 2
2 2
4 5
7 8
1 1
6 7
9 9
9 9
10 9
3 2
2 1
5 6
10 10
10 10
6 7
6 6
6 5
1 1
3 4
1 1
8 9
1 1
2 1
3 2
7 7
5 5
7 7
6 7
7 6
4 4...

output:

12
9
8
19
17
10
3
34
43
23
35
57
42
22
36
28
2044
2052
71
4
2069
56
21
83
5
94
33
26
2084
41
82
2
106
125
59
50
55
188
2116
72
189
14
32
69
73
96
48
99
15
75
44
2118
62
119
202
84
58
53
2129
92
126
86
70
108
128
60
213
112
2137
16
88
91
216
137
97
102
191
20
132
66
79
115
116
113
25
47
130
67
143
13...

result:

ok correct

Test #33:

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

input:

3326 8220
3 2
8 9
1 2
4 4
1 2
4 5
6 5
3 4
3 4
10 10
8 9
8 7
3 4
3 3
6 7
1 2
3 3
8 9
1 2
1 2
10 9
7 7
8 7
4 3
1 1
2 3
6 7
10 9
7 7
7 7
10 9
1 1
2 2
4 5
8 7
8 7
8 9
10 9
2 1
6 6
5 6
8 7
2 1
10 9
3 4
7 7
4 4
4 3
10 9
1 2
2 1
10 9
2 1
6 5
6 6
2 1
2 2
5 5
6 7
1 1
10 10
9 8
5 6
7 7
9 9
5 5
2 2
4 5
4 5
5 6...

output:

impossible

result:

ok impossible

Test #34:

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

input:

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

output:

4
2
1

result:

ok correct

Test #35:

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

input:

7 7
2 1
2 1
2 3
4 3
6 5
7 6
7 6
1 2 3 4 5 6 7

output:

1
2
3
4
5
6
7

result:

ok correct

Test #36:

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

input:

6 7
3 2
4 3
4 5
5 4
6 5
7 6
1 2 3 4 5 6 7

output:

impossible

result:

ok impossible

Test #37:

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

input:

3 3
3 4
5 6
8 9
6 7 8

output:

impossible

result:

ok impossible

Test #38:

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

input:

1 1
1 2
3

output:

impossible

result:

ok impossible

Test #39:

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

input:

3 3
100 101
101 101
101 102
101 101 101

output:

1
2
3

result:

ok correct