SlideShare a Scribd company logo
must use python
Task 04 (Cycle Finding): It was a very hectic day for Dora. Before going to sleep, Dora wants to
find out if there is any cycle in the map of the city. Since Dora has traveled the whole country
twice, she is feeling very exhausted and asks you to solve the problem. However, Dora has made
the roads of the cities directed in her map, so that you don't get bored. In graph theory, a cycle in
a graph is a non-empty trail in which only the first and last vertices are equal. [Wikipedia] Input:
The given map will be a directed and unweighted graph. The first line contains two integers N
and M ( 1 <= N , M <= 100 ) - the number of cities and the total number of roads. The next M
lines will contain two integers u i , v i ( 1 <= u i , v i <= N) - denoting there is a bidirectional
road between u i and v i . Output: Print "YES" if the map contains any CYcle, otherwise print
"NO".

More Related Content

More from KOCHHARHOSY

Ms- Carol Ramirez is a new resident in a long-term care facility based.pdf
Ms- Carol Ramirez is a new resident in a long-term care facility based.pdfMs- Carol Ramirez is a new resident in a long-term care facility based.pdf
Ms- Carol Ramirez is a new resident in a long-term care facility based.pdf
KOCHHARHOSY
 
Mr-X an individual is curiously researching to find what type of inves.pdf
Mr-X an individual is curiously researching to find what type of inves.pdfMr-X an individual is curiously researching to find what type of inves.pdf
Mr-X an individual is curiously researching to find what type of inves.pdf
KOCHHARHOSY
 
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdfMs- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
KOCHHARHOSY
 
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdfMrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
KOCHHARHOSY
 
Moving to another question will save this response Question 16 Part Ma.pdf
Moving to another question will save this response Question 16 Part Ma.pdfMoving to another question will save this response Question 16 Part Ma.pdf
Moving to another question will save this response Question 16 Part Ma.pdf
KOCHHARHOSY
 
Most of the brightest stars in the sky are Select an answer and submit.pdf
Most of the brightest stars in the sky are Select an answer and submit.pdfMost of the brightest stars in the sky are Select an answer and submit.pdf
Most of the brightest stars in the sky are Select an answer and submit.pdf
KOCHHARHOSY
 
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdfMr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
KOCHHARHOSY
 
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdfMr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
KOCHHARHOSY
 
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdfMPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
KOCHHARHOSY
 
mplete the following paragraph to explain the location and function of.pdf
mplete the following paragraph to explain the location and function of.pdfmplete the following paragraph to explain the location and function of.pdf
mplete the following paragraph to explain the location and function of.pdf
KOCHHARHOSY
 
Most lineages (species- genera- and broader clades) in North and Sout.pdf
Most lineages (species- genera- and broader clades)  in North and Sout.pdfMost lineages (species- genera- and broader clades)  in North and Sout.pdf
Most lineages (species- genera- and broader clades) in North and Sout.pdf
KOCHHARHOSY
 
Montserrat is studying creativity- She rates people's art on a scale o.pdf
Montserrat is studying creativity- She rates people's art on a scale o.pdfMontserrat is studying creativity- She rates people's art on a scale o.pdf
Montserrat is studying creativity- She rates people's art on a scale o.pdf
KOCHHARHOSY
 
Model organisms serve an important role in understanding human develop.pdf
Model organisms serve an important role in understanding human develop.pdfModel organisms serve an important role in understanding human develop.pdf
Model organisms serve an important role in understanding human develop.pdf
KOCHHARHOSY
 
Monoallelic expression is associated with which of the following- Mult.pdf
Monoallelic expression is associated with which of the following- Mult.pdfMonoallelic expression is associated with which of the following- Mult.pdf
Monoallelic expression is associated with which of the following- Mult.pdf
KOCHHARHOSY
 
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdfModule 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
KOCHHARHOSY
 
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdfModule 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
KOCHHARHOSY
 
modify the literal token so that it accepts unsigned floating point li (1).pdf
modify the literal token so that it accepts unsigned floating point li (1).pdfmodify the literal token so that it accepts unsigned floating point li (1).pdf
modify the literal token so that it accepts unsigned floating point li (1).pdf
KOCHHARHOSY
 
Modify your personType class to include 3 constructors- (In C++) 1- de.pdf
Modify your personType class to include 3 constructors- (In C++) 1- de.pdfModify your personType class to include 3 constructors- (In C++) 1- de.pdf
Modify your personType class to include 3 constructors- (In C++) 1- de.pdf
KOCHHARHOSY
 
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdfMinerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
KOCHHARHOSY
 
Michelle and Anthony met with the supervisor of the pizza division of.pdf
Michelle and Anthony met with the supervisor of the pizza division of.pdfMichelle and Anthony met with the supervisor of the pizza division of.pdf
Michelle and Anthony met with the supervisor of the pizza division of.pdf
KOCHHARHOSY
 

More from KOCHHARHOSY (20)

Ms- Carol Ramirez is a new resident in a long-term care facility based.pdf
Ms- Carol Ramirez is a new resident in a long-term care facility based.pdfMs- Carol Ramirez is a new resident in a long-term care facility based.pdf
Ms- Carol Ramirez is a new resident in a long-term care facility based.pdf
 
Mr-X an individual is curiously researching to find what type of inves.pdf
Mr-X an individual is curiously researching to find what type of inves.pdfMr-X an individual is curiously researching to find what type of inves.pdf
Mr-X an individual is curiously researching to find what type of inves.pdf
 
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdfMs- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
Ms- Petrie is a second-grade teacher- She realizes influenza season is (1).pdf
 
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdfMrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
Mrs- Randazzo is an elderly woman admitted to the hospital from a nurs.pdf
 
Moving to another question will save this response Question 16 Part Ma.pdf
Moving to another question will save this response Question 16 Part Ma.pdfMoving to another question will save this response Question 16 Part Ma.pdf
Moving to another question will save this response Question 16 Part Ma.pdf
 
Most of the brightest stars in the sky are Select an answer and submit.pdf
Most of the brightest stars in the sky are Select an answer and submit.pdfMost of the brightest stars in the sky are Select an answer and submit.pdf
Most of the brightest stars in the sky are Select an answer and submit.pdf
 
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdfMr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
Mr- and Mrs- Faurah- an immierant couple in their early 70 '- have bee.pdf
 
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdfMr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
Mr and Mrs- Longfoot have been mamed for 52 years- They both have medi.pdf
 
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdfMPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
MPI Incorporated has $3 billion in assets- and its tax rate is 25-- It.pdf
 
mplete the following paragraph to explain the location and function of.pdf
mplete the following paragraph to explain the location and function of.pdfmplete the following paragraph to explain the location and function of.pdf
mplete the following paragraph to explain the location and function of.pdf
 
Most lineages (species- genera- and broader clades) in North and Sout.pdf
Most lineages (species- genera- and broader clades)  in North and Sout.pdfMost lineages (species- genera- and broader clades)  in North and Sout.pdf
Most lineages (species- genera- and broader clades) in North and Sout.pdf
 
Montserrat is studying creativity- She rates people's art on a scale o.pdf
Montserrat is studying creativity- She rates people's art on a scale o.pdfMontserrat is studying creativity- She rates people's art on a scale o.pdf
Montserrat is studying creativity- She rates people's art on a scale o.pdf
 
Model organisms serve an important role in understanding human develop.pdf
Model organisms serve an important role in understanding human develop.pdfModel organisms serve an important role in understanding human develop.pdf
Model organisms serve an important role in understanding human develop.pdf
 
Monoallelic expression is associated with which of the following- Mult.pdf
Monoallelic expression is associated with which of the following- Mult.pdfMonoallelic expression is associated with which of the following- Mult.pdf
Monoallelic expression is associated with which of the following- Mult.pdf
 
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdfModule 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
Module 2- Spreadsheet Assignment I Graph each system of linear inequal.pdf
 
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdfModule 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
Module 2- Country Differences PLEASE DO THE FOLLOWING 1) Describe and.pdf
 
modify the literal token so that it accepts unsigned floating point li (1).pdf
modify the literal token so that it accepts unsigned floating point li (1).pdfmodify the literal token so that it accepts unsigned floating point li (1).pdf
modify the literal token so that it accepts unsigned floating point li (1).pdf
 
Modify your personType class to include 3 constructors- (In C++) 1- de.pdf
Modify your personType class to include 3 constructors- (In C++) 1- de.pdfModify your personType class to include 3 constructors- (In C++) 1- de.pdf
Modify your personType class to include 3 constructors- (In C++) 1- de.pdf
 
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdfMinerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
Minerals Quartz K-Feldspar Staurolite Chlorite Kaolinite Garnet Muscov (1).pdf
 
Michelle and Anthony met with the supervisor of the pizza division of.pdf
Michelle and Anthony met with the supervisor of the pizza division of.pdfMichelle and Anthony met with the supervisor of the pizza division of.pdf
Michelle and Anthony met with the supervisor of the pizza division of.pdf
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 

must use python Task 04 (Cycle Finding)- It was a very hectic day fo.pdf

  • 1. must use python Task 04 (Cycle Finding): It was a very hectic day for Dora. Before going to sleep, Dora wants to find out if there is any cycle in the map of the city. Since Dora has traveled the whole country twice, she is feeling very exhausted and asks you to solve the problem. However, Dora has made the roads of the cities directed in her map, so that you don't get bored. In graph theory, a cycle in a graph is a non-empty trail in which only the first and last vertices are equal. [Wikipedia] Input: The given map will be a directed and unweighted graph. The first line contains two integers N and M ( 1 <= N , M <= 100 ) - the number of cities and the total number of roads. The next M lines will contain two integers u i , v i ( 1 <= u i , v i <= N) - denoting there is a bidirectional road between u i and v i . Output: Print "YES" if the map contains any CYcle, otherwise print "NO".