• 个人简介

    # 你是我的苏湖熟足。

    层霄苍茫,极天太空; 东篱南山,悠然天涯。

    #include<bits/stdc++.h>
    using namespace std;
    const int N=2010;
    vector<int> g[N];
    int in[N],ans=0,n,m,v[N],level[N];
    struct sta{
    	int to,w;
    };
    void topsort(){
    	queue<int> q;
    	for(int i=1;i<=n+m;i++)
    		if(!in[i]){
    			q.push(i);
    			if(i<=n)	level[i]=1;
    		}
    	while(q.size()){
    		sta u=q.front();
    		q.pop();
    		for(sta v:g[u]){
    			if(--in[i]==0)	q.push({i,u.k+1});
    		}
    	}
    }
    int main(){
    	cin>>n>>m;
    	for(int i=1;i<=m;i++){
    		memset(v,0,sizeof(v));
    		int st=n,ed=1;x;
    		cin>>x;
    		while(x--){
    			int stop;
    			cin>>stop;
    			v[stop]=1;
    			st=min(st,stop);
    			ed=max(ed,stop);
    		}
    		int ver=n+i;
    		for(int i=st;i<=ed;i++){
    			if(v[i]){
    				g[ver].push_back({i,1});
    				in[i]++;
    			}
    			else{
    				g[i].push_back({ver,0});
    				in[ver]++;
    			}
    		}
    	}
    	topsort();
    	cout<<ans;
    	return 0;
    }
    
  • 最近活动

    This person is lazy and didn't join any contests or homework.