40分求助,其余全部WA,思路有漏洞吗?
查看原帖
40分求助,其余全部WA,思路有漏洞吗?
242490
lyc呐楼主2020/8/13 17:39
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	set <int> S;
	int T[n];
	int arr[100005]={0};
	vector <int> G[n];
	int ans=0,d=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
		int m;
		scanf("%d",&m);
		while(m--)
		{
			int x;
			arr[x]++;			//记录个数来决定是否要删除set内元素 
			G[i].push_back(x);	//G用来存储信息,方便后面更新set 
			scanf("%d",&x);
			S.insert(x);
		}
		while(T[i]-T[d]>=86400)	//如果当前船和船d时间差超过24h,更新set 
		{
			for(int i=0;i<G[d].size();i++)
			{
				arr[G[d][i]]--;	
				if(!arr[G[d][i]])	//如果G[d][i]国籍的人已经为0 
					S.erase(G[d][i]);//删除该元素			
			}
			d++;
		}
		ans=S.size();
		printf("%d\n",ans);
	}
 } 
2020/8/13 17:39
加载中...