求助,玄关
  • 板块灌水区
  • 楼主Mcfire05
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/13 20:36
  • 上次更新2024/10/14 07:24:24
查看原帖
求助,玄关
1075962
Mcfire05楼主2024/10/13 20:36

这是题目

代码如下

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
	ll s=0,w=1;
	char ch=getchar();
	while(ch<'0' or ch>'9'){
		if(ch=='-'){
			w=-1;
		}
		ch=getchar();
	}
	while(ch>='0' and ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}
vector<int>G[200900];
int main(){
	ios::sync_with_stdio(0);
	cout.tie(0);
	int c;
	cin>>c;
	ll n=read(),m=read(),k=read(),q=read();
	ll ans=n-1;
	for(ll i=0;i<m;i++){
		ll u=read(),v=read();
		G[u].push_back(v);
	}
	ll a[k];
	bool qwq[n+100]={0};
	qwq[1]=1;
	for(ll i=0;i<k;i++){
		a[i]=read();
	}
	for(ll i=0;i<q;i++){
		memset(qwq,0,sizeof(qwq));
		qwq[1]=1;
		ans=n-1;
		ll l=read(),r=read();
		for(int j=l-1;j<r;j++){
			for(int k=0;k<G[a[j]].size();k++){
				if((G[a[j]][k]==1  or qwq[G[a[j]][k]]==1) and qwq[a[j]]!=1){
					ans--;
					qwq[a[j]]=1;
					break;
				}
			}
		}
		cout<<ans<<'\n';
	}
}

然后爆零了

2024/10/13 20:36
加载中...