QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748105#9574. StripsQF_love_younger_sisterWA 24ms3856kbC++232.0kb2024-11-14 19:21:062024-11-14 19:21:08

Judging History

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

  • [2024-11-14 19:21:08]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3856kb
  • [2024-11-14 19:21:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N=2e5+10;
//int a[N],b[N];
struct shu{
	int zhi,bh;
}q[N];
int flag=1;
bool cmp(shu a,shu b){
	if(a.zhi==b.zhi && a.bh!=b.bh){
		flag=0;
	}
	return a.zhi<b.zhi;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m,k,w;
	int t;
	cin >> t;
	while(t--){
		flag=1;
		vector<int> da;
		cin >> n >> m >> k >> w;
		for(int i=1;i<=n;i++){
			cin >> q[i].zhi;
			q[i].bh=1;
		}
		for(int i=n+1;i<=n+m;i++){
			cin >> q[i].zhi;
			q[i].bh=2;
		}
		q[n+m+1].bh=2;
		q[n+m+1].zhi=w+1;
		q[0].zhi=0;
		q[0].bh=2;
		sort(q+1,q+1+n+m+1,cmp);
		if(flag){
			vector<int> dangda;
			int bws=0,aws=0,awm=0,bwm=0,fk=1,dang=0,dangw=0;
			int flag1=1;
			for(int i=1;i<=n+m+1;i++){
				if(q[i].bh==2){
					bws=bwm;
					bwm=i;
					if(!(aws==0&&awm==0) && fk==0){
						int bl=q[bwm].zhi-q[bws].zhi-1;
						int al=q[awm].zhi-q[aws].zhi+1;
						int bian=(al+k-1)/k*k;
						int tou=min(q[bwm].zhi-bian,q[aws].zhi);
						if(tou<=q[bws].zhi){
							flag1=0;
							break;
						}
						int lendang=dangda.size();
						if(lendang<(al+k-1)/k){
							for(int j=0;j<lendang;j++){
//								cout << "qf" << dangda[j] << "\n";
								da.push_back(dangda[j]);
							}
						}
						else{
							for(int j=0;j<(al+k-1)/k;j++){
								da.push_back(tou+k*j);
							}
						}
					}
					fk=1;
					dang=0;
					dangw=0;
					dangda.clear();
				}
				if(q[i].bh==1){
					if(fk==1){
						fk=0;
						aws=i;
						awm=i;
						dang++;
						dangw=q[i].zhi+k-1;
						dangda.push_back(q[i].zhi);
					}
					else{
						if(q[i].zhi>dangw){
							dang++;
							dangw=q[i].zhi+k-1;
							dangda.push_back(q[i].zhi);
						}
						awm++;
					}
				}
			}
			if(flag1){
				int len2=da.size();
				cout << len2 << "\n";
				for(int i=0;i<len2;i++){
					cout << da[i] << " ";
				}
				cout << "\n";
			}
			else cout << "-1" << "\n";
		}
		else{
			cout << "-1" << "\n";
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
5 2 3 16
7 11 2 9 14
13 5
3 2 4 11
6 10 2
1 11
2 1 2 6
1 5
3
2 1 2 6
1 5
2

output:

4
2 7 10 14 
-1
2
1 5 
-1

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 24ms
memory: 3824kb

input:

11000
3 8 2 53
32 3 33
35 19 38 20 1 30 10 6
7 10 1 42
3 14 4 36 28 40 22
17 20 12 41 27 7 1 19 13 9
6 6 13 78
55 76 53 32 54 58
62 45 21 4 7 61
8 7 3 68
9 26 54 31 22 3 38 65
34 16 58 47 52 29 53
5 8 4 33
33 5 30 6 15
27 12 9 28 19 2 13 10
6 1 2 48
8 12 48 1 41 31
40
7 6 7 61
20 19 30 52 49 17 40
3...

output:

2
3 32 
7
3 4 14 22 28 36 40 
3
32 48 66 
8
3 9 22 25 31 38 54 65 
3
5 15 30 
6
1 8 12 31 41 48 
4
17 30 37 49 
2
52 67 
1
27 
1
22 
1
62 
5
24 33 43 48 60 
2
4 31 
3
11 19 31 
3
3 16 33 
3
25 30 42 
3
3 17 60 
4
1 11 21 33 
2
54 66 
3
50 59 65 
3
50 60 78 
1
81 
4
2 11 16 23 
-1
2
1 45 
2
7 25 
1
4...

result:

wrong answer Integer parameter [name=l_i] equals to 48, violates the range [1, 47] (test case 6)