QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762149#9574. Stripsszy10010WA 42ms3732kbC++231.5kb2024-11-19 13:57:202024-11-19 13:57:20

Judging History

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

  • [2024-11-19 13:57:20]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:3732kb
  • [2024-11-19 13:57:20]
  • 提交

answer

#include<iostream>
#include<set>
#include<queue>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
#include<unordered_map>

#define pb push_back
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(),(x).end()
#define _for(i, a) for(int i = 0; i < (a); ++i) 
#define _rep(i, a, b) for(int i = (a);i <= (b); ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define u1 (u<<1)
#define u2 (u<<1|1)
//#define endl '\n'
using namespace std;
typedef pair<int,int> PII;

const int INF=0x3f3f3f3f;
const int P=1e9+7;
const int N=1e5+20,M=2*N;
int n,m,k,w,num;
void solve(){
	vector<int> v;
	cin>>n>>m>>k>>w;
	priority_queue<int,vector<int>,greater<>> q;
	_for(i,n){
		cin>>num;
		q.push(num);
	}
	_for(i,m){
		cin>>num;
		v.pb(num);
	}
	v.pb(0);
	v.pb(w+1);
	sort(all(v));
	vector<int> res;
	_rep(i,1,v.size()-1){
		vector<PII> ans;
		int l=v[i-1];
		int r=v[i];
		int now=l;
		while(q.size()&&q.top()<=r){
			int t=q.top();
			if(t==v[i]){
				cout<<-1<<endl;
				return;
			}
			if(now<t){
				ans.pb({t,t-now-1});
				now=t+k-1;
			}
			q.pop();	
		}
		int d=max(now-r+1,(int)0);
		for(int i=ans.size()-1;i>=0;i--){
			int t=min(d,ans[i].se);
			res.pb(ans[i].fi-t);
			d-=t;
		}
		if(d>0){
			cout<<-1<<endl;
			return;
		}
	}
	cout<<res.size()<<endl;
	_for(i,res.size()){
		cout<<res[i]<<" ";
	}
	cout<<endl;
}
signed main(){
	IOS;
	int T=1;
	cin>>T;
	_rep(i,1,T){
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3504kb

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

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 42ms
memory: 3732kb

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
4 3 14 22 40 36 28 
3
32 48 66 
8
9 3 26 22 31 38 54 65 
3
5 15 30 
6
31 12 8 1 47 41 
4
17 39 30 49 
2
67 52 
1
27 
1
22 
1
62 
5
24 43 33 60 48 
2
4 31 
3
20 11 31 
3
3 16 33 
3
30 25 42 
3
3 17 60 
4
25 12 1 33 
2
66 54 
3
50 59 65 
3
62 50 78 
1
81 
4
2 11 23 16 
5
3 7 36 17 49 
2
1 45...

result:

wrong answer There is at least one stripe covering black cell 31 (test case 18)