Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int a[100][100],s,n,m,h[100];
- void citire()
- {
- ifstream fin("graf.in");
- fin>>n>>m>>s;
- for(int i=1;i<=m;i++)
- {
- int x,y;
- fin>>x>>y;
- a[x][y]=1;
- a[y][x]=1;
- }
- for(int i=1;i<=n;i++)
- fin>>h[i];
- }
- int main()
- {
- citire();
- for(int i=1;i<=n;i++)
- {
- if(i==s)
- {
- for(int j=1;j<=n;j++)
- {
- if(a[i][j]==1 && h[i]<=h[j])
- {
- cout<<j<<" camera inundata "<<i<<" "<<j<<" culoar umezit ";
- for(int k=s+1;k<=n;k++)
- {
- if(a[j][k]==1 && h[j]<=h[k])
- {
- cout<<k<<" camera inundata "<<j<<" "<<k<<" culoar umezit ";
- cout<<endl;
- }
- cout<<endl;
- }
- }
- cout<<endl;
- }
- }
- }
- return 0;
- }
- 6 6 3
- 1 2
- 2 3
- 3 4
- 3 5
- 4 5
- 3 6
- 3 6 4 7 1 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement