QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608727#2412. Canvas Linekevinyang#WA 1ms3804kbC++141.3kb2024-10-04 01:44:422024-10-04 01:44:43

Judging History

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

  • [2024-10-04 01:44:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-10-04 01:44:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pii>a(n+1);
	for(int i = 1; i<=n; i++){
		int l,r;
		cin >> l >> r;
		a[i] = {l,r};
	}
	vector<int>c(n+1);
	int k;
	cin >> k;
	map<int,int>hm;

	for(int i = 0; i<k; i++){
		int x;
		cin >> x;
		for(int i = 1; i<=n; i++){
			if(a[i].first <= x && x<=a[i].second){
				c[i]++;
			}
		}
		hm[x] = 1;
	}
	for(int i = 1; i<=n; i++){
		if(c[i] >= 3){
			cout << "impossible\n";
			return 0;
		}
	}

	vector<int>add(n+1);
	vector<int>ans;
	for(int i = 2; i<=n; i++){
		if(c[i] <= 1 && c[i-1] <= 1 && !hm.count(a[i].first)){
			c[i-1]++;
			c[i]++;
			ans.push_back(a[i].first);
		}
	}
	for(int i = 1; i<=n; i++){
		if(c[i] == 2){
			continue;
		}
		for(int j = a[i].first+1; j<a[i].second && c[i] < 2; j++){
			if(hm.count(j))continue;
			c[i]++;
			ans.push_back(j);
		}
	}
	cout << ans.size() << '\n';
	for(int i = 0; i<ans.size(); i++){
		cout << ans[i];
		if(i+1<ans.size())cout << ' ';
	}
	cout << '\n';

	return 0;
}

详细

Test #1:

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

input:

5
0 100
100 200
200 300
300 400
400 500
2
100 200

output:

4
300 400 1 401

result:

ok 

Test #2:

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

input:

20
0 100
100 200
200 300
300 400
400 500
500 600
600 700
700 800
800 900
900 1000
1000 1100
1100 1200
1200 1300
1300 1400
1400 1500
1500 1600
1600 1700
1700 1800
1800 1900
1900 2000
3
300 900 2000

output:

18
100 200 400 500 600 700 800 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 1

result:

ok 

Test #3:

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

input:

300
0 10
10 20
20 30
30 40
40 50
50 60
60 70
70 80
80 90
90 100
100 110
110 120
120 130
130 140
140 150
150 160
160 170
170 180
180 190
190 200
200 210
210 220
220 230
230 240
240 250
250 260
260 270
270 280
280 290
290 300
300 310
310 320
320 330
330 340
340 350
350 360
360 370
370 380
380 390
390 ...

output:

299
10 50 60 70 80 100 110 130 160 170 180 190 200 220 230 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 8...

result:

ok 

Test #4:

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

input:

1
9000 9020
2
8990 9030

output:

2
9001 9002

result:

ok 

Test #5:

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

input:

2
0 10
10 20
1
10

output:

2
1 11

result:

ok 

Test #6:

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

input:

2
0 10
10 20
1
0

output:

2
10 11

result:

ok 

Test #7:

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

input:

3
0 20
20 30
30 50
4
0 10 40 50

output:

2
21 22

result:

ok 

Test #8:

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

input:

2
3000 13000
13010 13100
5
9120 11900 13000 13010 13090

output:

impossible

result:

ok 

Test #9:

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

input:

1
10 10000
1000
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 590...

output:

impossible

result:

ok 

Test #10:

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

input:

4
0 18
18 28
28 40
49 60
4
6 12 35 60

output:

3
28 19 50

result:

ok 

Test #11:

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

input:

2
0 10
20 30
2
0 10

output:

2
21 22

result:

ok 

Test #12:

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

input:

2
0 10
10 20
0


output:

3
10 1 11

result:

ok 

Test #13:

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

input:

4
500 510
510 520
530 540
540 550
3
510 520 540

output:

3
501 531 541

result:

ok 

Test #14:

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

input:

1000
0 10
20 30
40 50
60 70
80 90
100 110
120 130
140 150
160 170
180 190
200 210
220 230
240 250
260 270
280 290
300 310
320 330
340 350
360 370
380 390
400 410
420 430
440 450
460 470
480 490
500 510
520 530
540 550
560 570
580 590
600 610
620 630
640 650
660 670
680 690
700 710
720 730
740 750
76...

output:

532
20 60 100 140 180 220 260 300 340 380 420 460 520 560 660 700 740 780 820 860 900 940 980 1020 1060 1140 1200 1240 1280 1320 1360 1400 1460 1500 1540 1580 1620 1660 1700 1740 1780 1820 1860 1900 1940 1980 2020 2060 2100 2140 2180 2220 2260 2300 2340 2380 2420 2480 2520 2560 2600 2640 2680 2720 2...

result:

wrong answer Team used pegs=1 in sheet 1