40分求助
查看原帖
40分求助
338786
mushroom_knight楼主2020/5/4 19:47

RT

#include<bits/stdc++.h>
using namespace std;
int tf=86400;
int boat[100001];
int many[100001];
int from[300001];
int n,m;
int vis[300001];
int ans[300001];
inline int read(){
	int x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-1;
		}
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int main(){
	int tot=0;
	int begin=1;
	int tmp=0;
	int cnt=0;
	n=read();
	for(register int i=1;i<=n;++i){
		boat[i]=read();
		many[i]=read();
		for(register int j=1;j<=many[i];++j){
			from[j]=read();	
			if(vis[from[j]]==0){
				cnt++;
			}
			++vis[from[j]];	
		}
		while(boat[i]-boat[++tot]>tf){
			for(register int l=1;l<=many[i];++l){
				--vis[from[l]];
				if(vis[from[l]]==0){
					cnt--;
				}
			}
		}
		ans[i]=cnt;
	}
	/*for(register int i=1;i<=n;++i){
		while(boat[i]-boat[++tmp]>tf){
			tot++;
			for(register int i=1;i<=tot-1;++i){
				--vis[from[tot][i]];
			}
		}
		print(i);
	}*/
	for(register int i=1;i<=n;++i){
		cout<<ans[i]<<endl;
	}
	return 0;
}

记录

2020/5/4 19:47
加载中...