Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
0474 - Verif Lant
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Rezolvare == <syntaxhighlight lang="python3" line="1"> def citire_graf(muchii): graf = {} for i, j in muchii: if i not in graf: graf[i] = [] if j not in graf: graf[j] = [] graf[i].append(j) graf[j].append(i) return graf def este_lant(graf, sir): for i in range(len(sir) - 1): if sir[i + 1] not in graf[sir[i]]: return False return True def este_elementar(sir): return len(set(sir)) == len(sir) def verifica_restrictii(n, muchii, k, vrf_siruri): if not (1 <= n <= 100): return False for i, j in muchii: if not (1 <= i <= n and 1 <= j <= n): return False if not (1 <= k <= 100): return False for sir in vrf_siruri: if not (len(sir) < 200): return False return True # Deschideți fișierele de intrare și ieșire with open("veriflantIN.txt", "r") as input_file, open("veriflantOUT.txt", "w") as output_file: n, m = map(int, input_file.readline().split()) muchii = [tuple(map(int, input_file.readline().split())) for _ in range(m)] try: k = int(input_file.readline()) except ValueError: output_file.write("Datele nu corespund restrictiilor impuse\n") exit() vrf_siruri = [list(map(int, input_file.readline().split()[1:])) for _ in range(k)] if verifica_restrictii(n, muchii, k, vrf_siruri): graf = citire_graf(muchii) for vrf_sir in vrf_siruri: if este_lant(graf, vrf_sir): if este_elementar(vrf_sir): output_file.write("ELEMENTAR\n") else: output_file.write("NEELEMENTAR\n") else: output_file.write("NU\n") else: output_file.write("Datele nu corespund restrictiilor impuse\n") </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width