70分玄关求调QAQ
查看原帖
70分玄关求调QAQ
1177185
DRheEheAM_Gary楼主2024/8/24 14:26

全是TLE(qwq

#include<bits/stdc++.h>
using namespace std;
struct Ti{
    int t,i;
};
int n,t[100005],k[100005];
vector<int> x[100005];
queue<Ti> ti;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i]>>k[i];
        for(int j=1;j<=k[i];j++){
            int x;
            cin>>x;
            ::x[i].push_back(x);
        }
    }
    for(int i=1;i<=n;i++){
        ti.push((Ti){t[i],i});
        while(t[i]-ti.front().t>86400) ti.pop();
        int l=(int)ti.size();
        int ans=0;
        map<int,int> hs;
        while(l--){
            Ti ti=::ti.front();
            ::ti.push(ti);
            ::ti.pop();
            for(int i=0;i<k[ti.i];i++){
                if(!hs.count(x[ti.i][i])){
                    ans++;
                    hs[x[ti.i][i]]=1;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
2024/8/24 14:26
加载中...