为什么会RE??????????????
查看原帖
为什么会RE??????????????
371925
Cosmos_zzx楼主2023/6/22 11:57
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,a[10000001],l=1,r=1e9,ans,tot=1,n1,t[1000001];
signed main()
{
    cin>>n1>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>t[i];
        for(int j=1;j<=t[i];j++)
        {
            int x;
            cin>>x;
            a[x]=t[i];
            n=max(n,x);
        }
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<endl;
    m++;
    int i=1;
    int sum=0,flag[2000001];
    memset(flag,0,sizeof(flag));
    while(i<=tot && tot<=n)
    {
        while(sum<m && tot<=n)
        {
            if(!flag[a[tot]])sum++;
            flag[a[tot]]++;
            tot++;
        }
        if(sum<m)break;
        if(tot-i<r-l+1)l=i,r=tot-1;
        if(flag[a[i]]==1)sum--;
        flag[a[i]]--;
        i++;
    }
    cout<<l<<' '<<r<<endl;
    return 0;
}
2023/6/22 11:57
加载中...