社区讨论

查错

P2827[NOIP 2016 提高组] 蚯蚓参与者 2已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@mi7cnc86
此快照首次捕获于
2025/11/20 19:29
4 个月前
此快照最后确认于
2025/11/20 19:29
4 个月前
查看原帖
50分代码,我觉得没有错啊? #2,#3,#4,#5,#6,#8 RE(当然我数组后来改大了) #9,#10,#11,#13 WA
C
#include<bits/stdc++.h>
using namespace std;
#define reg register 

int n,m,q,u,v,t;
int a[4][300005],top[4]={0,1,1,1},rear[4],tot[4];//2>3

inline int read()
{
	reg int res=0,flg=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flg=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {res=(res<<3)+(res<<1)+(ch^48);ch=getchar();}
	return res*flg;
}
inline bool cmp(int a,int b){return a>b;}
inline int find()
{
	int tp1=a[1][top[1]]+tot[1],tp2=a[2][top[2]]+tot[2],tp3=a[3][top[3]]+tot[3];
	if(top[1]<=rear[1]&&tp1>=tp2&&tp1>=tp3) {top[1]++;return tp1;}
	if(top[2]<=rear[2]&&(top[1]>rear[1]||tp2>=tp1)&&tp2>=tp3) {top[2]++;return tp2;}
	top[3]++;return tp3;
}
inline void print()
{
	for(int i=1;i<=3;i++)
	{
		printf("%d: ",i);
		for(int j=top[i];j<=rear[i];j++)
			printf("%d ",a[i][j]+tot[i]);
		puts("");
	}
}
int main(){
	n=read();	m=read();	q=read();
	u=read();	v=read();	t=read();
	for(reg int i=1;i<=n;i++) a[1][i]=read();
	sort(a[1]+1,a[1]+n+1,cmp);rear[1]=n;
	for(reg int i=1;i<=m;i++)
	{
		int cd=find();
		if(i%t==0) printf("%d ",cd);
		int c1=(cd*u)/v-q;
		int c2=cd-(cd*u)/v-q;
		if(c1>c2)
			c1-=tot[2],a[2][++rear[2]]=c1,
			c2-=tot[3],a[3][++rear[3]]=c2;
		else c2-=tot[2],a[2][++rear[2]]=c2,
			 c1-=tot[3],a[3][++rear[3]]=c1;
		tot[1]+=q;	tot[2]+=q;	tot[3]+=q;
	}
	puts("");
	for(reg int i=1;i;i++)
	{
		int xc=find();
		if(i%t==0) printf("%d ",xc);
		if(top[1]>rear[1]&&top[2]>rear[2]&&top[3]>rear[3]) break;
	}
	puts("");
	return 0;
}
print函数是调试用的请忽略...
不要恶意回复谢谢
话说我前排左边那位要我发“萌新刚学OI?!!!”

回复

4 条回复,欢迎继续交流。

正在加载回复...