QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#729349#9574. Stripsucup-team3282#WA 0ms3604kbC++201.4kb2024-11-09 16:57:352024-11-09 16:57:36

Judging History

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

  • [2024-11-09 16:57:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-11-09 16:57:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;

int n,m,k,w;
int a[maxn];
int b[maxn];
pair<int,bool> t[maxn*2];

vector<int> ans;

int main(){
	ios::sync_with_stdio();
	int T;
	cin>>T;
	while(T--){
		cin>>n>>m>>k>>w;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		for(int i=1;i<=m;i++)
			cin>>b[i];
		
		for(int i=1;i<=n;i++)
			t[i]={a[i],0};
		for(int i=n+1;i<=n+m;i++)
			t[i]={b[i-n],1};
		t[n+m+1]={w+1,1};
		t[0]={0,1};
		
		sort(t+1,t+n+m+2);
		int lp=0,rp=0;
		
		ans.clear();
		for(int i=1;i<=n+m+1;i++){
			if(t[i].second){
				rp=i;
				int cnt=0,r=-k;
				vector<int> res;
				for(int j=lp+1;j<rp;j++){
					if(r+k-1<t[j].first){
						r=t[j].first;
						cnt++;
						res.push_back(r);
					}
				}
				lp=rp;
//				cout<<"t "<<t[lp].first<<' '<<t[rp].first<<endl;
				if((ll)cnt*k>t[rp].first-t[lp].first-1){
					ans.clear();
					break;
				}
				if(res.empty())
					continue;
				if(res.back()+k-1>=t[rp].first){
					res.back()=t[rp].first-k;
				}
				for(int id=cnt-2;id>=0;id--){
					if(res[id]+k-1>=res[id+1])
						res[id]=res[id+1]-k;
				}
				for(int tmp:res)
					ans.push_back(tmp);
			}
		}
		if(ans.empty()){
			cout<<-1<<endl;
		}
		else{
			cout<<ans.size()<<endl;
			for(int t:ans)
				cout<<t<<' ';
			cout<<endl;
		}
	}
		
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

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:

-1
-1
-1
-1

result:

wrong answer Participant didn't find a solution but the jury found one. (test case 1)