关于卡常
查看原帖
关于卡常
363669
hwwqy楼主2021/8/31 22:19

rt
P2058 [NOIP2016 普及组] 海港

#include<nuts/stdc++.h>
using namespace std;
struct cxk{
	int gj;
	int t;
};
cxk a[500100];
int b[300100];
int qtop=1,qtail=1;
//a=sblwz
int main()
{
	//ios::sync_with_stdio(false);
	int n;
	scanf("%d",&n);
	int ans=0;
	while(n--)
	{
		int t,k;
		scanf("%d%d",&t,&k);
		for(int i=1;i<=k;++i)
		{
			scanf("%d",&a[qtail].gj);
			if(b[a[qtail].gj]==0)ans++;
			b[a[qtail].gj]++;
			
			a[qtail].t=t;
			qtail++;
		}
		//cout<<"qtail:"<<qtail<<endl;
		//memset(b,0,sizeof(b));		
		for(int i=qtop;i<qtail;++i)
		{
			if(t-a[i].t>=86400)
			{				
				
				if(b[a[qtop].gj]!=0)b[a[qtop].gj]--;
				if(b[a[qtop].gj]==0)ans--;
				qtop++;
			}
			
		}		
		printf("%d\n",ans);
		
	}
	return 0;
}
/*
3
1 4 4 1 2 2
2 2 2 3
10 1 3
*/
/*

4
1 4 1 2 2 3
3 2 2 3
86401 2 3 4
86402 1 5
*/

为啥把int改成register int就AC了
常数真的有那么大的影响吗?
常数真的能带来这么大的影响吗?
wgzs

2021/8/31 22:19
加载中...