15pts求调
查看原帖
15pts求调
537836
sxxxxy楼主2025/8/5 09:37
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
int n,m,k,nl,nul,nlll;
int pos[maxn];
bool b[maxn];
int main()
{
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++)
	{
		cin>>nl;
		pos[i]=nl;
		b[nl]=1;
	}
	int cnt=1;
	for(int i=m+1;i<=n;cnt++)
	{
		if(b[cnt]==0)
		{
			pos[i]=cnt;
			i++;
		}
	}
	nul=m+1;
	if(n-m>m*k||k>n-m)
	{
		cout<<"-1";
		return 0;
	}
	for(nlll=1;nlll<=(n-m)/(k+1);nlll++)
	{
		cout<<pos[nlll]<<" "<<pos[nul]<<endl;
		for(;nul<m+k*nlll;nul++)
			cout<<pos[nul]<<" "<<pos[nul+1]<<endl;
		cout<<pos[nul]<<" "<<pos[1]<<endl;
		nul++;
	}
	nul--;
	if(n-m-(k*(nlll-1))>0)
	{
		cout<<pos[nlll]<<" "<<pos[++nul]<<endl;
		for(;nul<n;nul++)
			cout<<pos[nul]<<" "<<pos[nul+1]<<endl;
		cout<<pos[nul]<<" "<<pos[1]<<endl;
	}
	nlll++;
	for(;nlll<=m;nlll++)
		cout<<pos[nlll]<<" "<<pos[1]<<endl;
	return 0;
	/*本人思路是前若干个奶龙独自走完k个空点,
	剩余的小于k个空点由一个奶龙走,走完了再回
	头走第一个奶龙走的路,最后剩余的若干个奶龙
	直接走第一个奶龙走过的路,思路应该没问题,
	自己造的数据都能过,但就是会WA好几个点,求
	大佬指导*/
}
2025/8/5 09:37
加载中...