逆天
  • 板块灌水区
  • 楼主whileAK
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/5/9 18:16
  • 上次更新2024/5/9 20:20:45
查看原帖
逆天
817925
whileAK楼主2024/5/9 18:16

求助大佬,为啥这份代码读入一个长1e5的链会RE?

dfs都能挂,是不是可以退役了

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void rd(int &p){
    int f=1;p=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9')p=(p<<1)+(p<<3)+c-'0',c=getchar();
    p*=f;
}
void rdl(ll &p){
    ll f=1;p=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9')p=(p<<1)+(p<<3)+c-'0',c=getchar();
    p*=f;
}
const int N=2e5+50;
int n,m,cnt(0);
vector<int>v[N];
bool b[N];
void ct(int p,int fa){
	++cnt;if(p>25900)cout<<p<<endl;
	for(int i(0);i<v[p].size();++i){
		if((v[p][i]!=fa)&&(!b[v[p][i]])){
			//if(p>25900)cout<<p<<' '<<endl;
			ct(v[p][i],p);
		}
	}
}
int main(){
	freopen("data.in","r",stdin);
	freopen("shaber.out","w",stdout);
	rd(n);rd(m);memset(b,false,sizeof(b));
	for(int i(1),x,y;i<n;++i){
		rd(x);rd(y);v[x].push_back(y);v[y].push_back(x);
	}
	for(int i(1);i<=n;++i)printf("%d ",v[i].size());cout<<endl;
	cout<<25909<<' '<<v[25909][0]<<' '<<v[25909][1]<<endl;
	ct(1,0);cout<<"K"<<endl;
    return 0;
}
2024/5/9 18:16
加载中...