Notes
![]() ![]() Notes - notes.io |
There are several outdoor movie sets in Beykoz Kundura, each of which consist of several streets and their intersections. Specifically, each street connects 2 intersections.
In order to secure these movie sets, and remove any fans snooping around, security guards are going to be placed in certain intersections of every set.
A security guard placed at an intersection A can cover all the intersections adjacent to A. (and the streets between intersection A and those neighboring intersections) Being a chatty bunch, however, if a street is covered by more than 1 security guards, they start chatting with one another and miss any movie fans walking around the set. Kundura is fun and all, but chatty security guards are not allowed to work in here!
Given the information about the movie sets and about the security guards, it is time to give back to the Kundura community! Help them find out the minimum number of total security guards required to cover every part of each outdoor movie set.
Input Format
The first line contains 2 integers I and S, indicating the total number of intersections and streets in the movie sets of Beykoz Kundura.
Each of the next S lines contains 2 integers a and b, denoting that there is a street between the intersections with index a and b.
Constraints
The intersections are 1-indexed.
1 <= I <= 200
1 <= S <= 10000
1 <= a, b <= I
Output Format
Print an integer denoting the minimum number of security guards required. If it is impossible to place the security guards so that none of them chat with each other, print -1.
Sample Input 0
4 2
1 2
3 4
Sample Output 0
2
Sample Input 1
5 5
1 2
2 3
3 4
1 5
4 5
Sample Output 1
-1
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team