QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#763217#9574. Stripsszy10010WA 23ms5912kbC++232.3kb2024-11-19 19:00:142024-11-19 19:00:15

Judging History

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

  • [2024-11-19 19:00:15]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:5912kb
  • [2024-11-19 19:00:14]
  • 提交

answer

#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define pb emplace_back
#define pp pop_back()
#define int long long
#define laile cout<<"laile"<<endl
#define lowbit(x) ((x)&(-x))
#define double long double
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sd(x) scanf("%Lf",&x)
#define sdd(x,y) scanf("%Lf %Lf",&x,&y)
#define _for(i,n) for(int i=0;i<(n);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _pre(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
const int N=1e6+10,INF=4e18;
int n,m,k,w;
int a[N],b[N];
vector<int>res;
bool deal(vector<int>&v,int l,int r)
{
	int R=v.back()+k-1;
	vector<int>offset;
	int needdis=R-r+1;
//	cout<<"nedis"<<needdis<<endl;
	int pre=l;
//	cout<<"v"<<endl;
//	cout<<l<<"-----";
	for(auto i:v)
	{
//		cout<<i<<" ";
		offset.pb(i-pre-1);
		pre=i+k-1;
	}
//	cout<<endl;
//	cout<<"offs/et:"<<" ";
//	for(auto i:offset)cout<<i<<" ";
//	cout<<endl;
//	cout<<"-----"<<r;
//	cout<<endl;
	bool bl=false;
	for(int i=(int)v.size()-1;i>=0;i--)
	{
		if(!bl)
		{
			if(needdis>offset[i])needdis-=offset[i];
			else 
			{
				int now=v[i]-needdis;
				needdis=0;
				while(now<r)
				{
					res.pb(now);
					now+=k;
				}
				bl=true;
			}
		}
		else 
			res.pb(v[i]);
	}
//	cout<<"needdis="<<needdis<<endl;
	return needdis<=0;
}
void solve()
{
	cin>>n>>m>>k>>w;
	res.clear();
	_rep(i,1,n)cin>>a[i];
	_rep(i,1,m)cin>>b[i];
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	b[m+1]=w+1;
	int l=1;
	_rep(i,1,m+1)
	{
		vector<int>v;
		int nowl=a[l],nowr=-1;
		while(l<=n&&a[l]<b[i])
		{
			if(a[l]>nowr)v.pb(a[l]),nowr=a[l]+k-1;
			l++;
		}
		if(v.size())
		{
			if(!deal(v,b[i-1],b[i]))
			{
				cout<<"-1\n";
				return;
			}
		}
	}
	cout<<(int)res.size()<<'\n';
	for(auto i:res)cout<<i<<" ";
	cout<<'\n';
	return ;
}
signed main()
{
	IOS;
	int T=1;
    cin>>T;
	while(T--)
		solve();
	return 0;
}

詳細信息

Test #1:

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

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: 23ms
memory: 5656kb

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
4 33 
7
6 3 16 26 40 36 28 
3
32 48 66 
8
13 3 26 22 31 44 55 66 
3
5 15 30 
6
38 12 8 1 47 41 
4
17 39 30 55 
2
84 52 
1
31 
1
22 
1
62 
5
24 43 33 64 48 
2
16 57 
3
20 11 31 
3
3 18 33 
3
30 25 79 
3
3 28 60 
4
1 11 21 33 
2
66 54 
3
50 60 69 
3
67 50 79 
1
81 
4
4 11 43 16 
5
3 14 36 17 50 
2
1...

result:

wrong answer There is no stripe covering red cell 3 (test case 1)