70分,T爆
查看原帖
70分,T爆
278259
RemiliaScar1et楼主2020/4/29 08:00

TLE , yzm TLE

谁来救救孩子

#include <bits/stdc++.h>
using namespace std;
int mes[300010];
int ship[100010][5];
bool list_[100010];
int n;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("port.in","r",stdin);
//	freopen("port.out","w",stdout);
	cin>>n;
	int num=0;
	for(int i=1;i<=n;++i)
	{
		cin>>ship[i][1]>>ship[i][2];
		ship[i][3]=num;
		int j;
		for(j=1;j<=ship[i][2];++j)
		{
			cin>>mes[num+j];
		}
		num+=j;
		--num;
		
	}
//	cout<<endl<<"mes:";
//	for(int i=1;i<=num;i++)
//	{
//		cout<<mes[i]<<" ";
//	}
//	cout<<endl;
	for(int i=1;i<=n;++i)
	{
		memset(list_,0,sizeof(list_));
		int l=1,r=i,mid;
		while(l<r)
		{
			mid=(l+r)>>1;
			if(ship[mid][1]<=ship[i][1]-86400) 
			{
				l=mid+1;
//				cout<<"l"<<l<<" ";
			}
			else 
			{
				r=mid;
//				cout<<"r"<<r<<" ";
			}
		}
//		cout<<"L"<<l<<" ";
		int maxn=-9999999,minn=9999999;
		int ans=0;
		for(int j=ship[l][3]+1;j<=ship[i][3]+ship[i][2];++j)
		{
//			cout<<"qwq"<<mes[j]<<" ";
			if(list_[mes[j]]==0)
			{
//				cout<<"M"<<mes[j]<<" ";
				list_[mes[j]]=1;
				++ans;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


2020/4/29 08:00
加载中...