成功题解:https://ycwy-zd-rz.blog.luogu.org/cogs152-post
其实就是一道bfs水题,加了freopen后基本上都会过. [cpp]#include<bits/stdc++.h> using namespace std; #define s freopen("mud.in","r",stdin) #define ss freopen("mud.out","w",stdout) #define sss fclose(stdin) #define ssss fclose(stdout) #define mint int// long #define pd if(nx<=maxx && ny<=maxx && nx>=0 && ny>=0 && !mp[nx][ny]) mint mp[1010][1010]; mint rock,ax,ay; mint maxx=1010; mint hd,tl; mint dx[]={0,0,0,1,-1}; mi[][/cpp] |
|
https://ycwy-zd-rz.blog.luogu.org/cogs3008-post
//爱八卦的小朋友们 //爱八卦的小朋友们 [code=cpp]#include<bits/stdc++.h> using namespace std; #define mint long long int mint n,m,ans; bool f[10001]; struct u{ mint x,y; }; u n[10001]; int main(){ freopen("friendscircle.in","r",stdin); freopen("friendscircle.out","w",stdout); cin>>n>>m; int a=1; f[a]=true; for(mint i=1;i<=m;i++){ cin>>n[i].x>>n[i].y; } for(mint j=1;j<=n;j++) for(mint i=1;i<=m;i++){ if(f[n[i].x] ) f[n[i].y]=true; else if(f[n[i].y] ) f[n[ |