QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748144#9574. StripsQF_love_younger_sisterWA 0ms3620kbC++232.1kb2024-11-14 19:28:512024-11-14 19:28:51

Judging History

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

  • [2024-11-14 19:28:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-14 19:28:51]
  • 提交

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<pair<int,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();
						int qian=q[bwm].zhi;
						for(int i=lendang-1;i>=0;i--){
							if(dangda[i].second>=qian){
								dangda[i].second-=(dangda[i].second-qian+1);
								qian=dangda[i].first-(dangda[i].second-qian+1);
							}
							else qian=dangda[i].first;
							da.push_back(qian);
						}
					}
					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,dangw});
					}
					else{
						if(q[i].zhi>dangw){
							dang++;
							dangw=q[i].zhi+k-1;
							dangda.push_back({q[i].zhi,dangw});
						}
						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: 0
Wrong Answer
time: 0ms
memory: 3620kb

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 11 7 14 
-1
2
1 5 
-1

result:

wrong answer There is at least one stripe covering black cell 13 (test case 1)