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
3219 - Colina
(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 ver. 1=== <syntaxhighlight lang="python" line="1" start="1"> import os def validare_intrare(N: int, M: int, altitudini: list[int], cereri: list[int]): if N < 1 or N > 100000: print("Valoarea lui N nu respecta restrictiile problemei!") return False if M < 1 or M > 100000: print("Valoarea lui M nu respecta restrictiile problemei!") return False if len(altitudini) != N or len(cereri) != M: print("Numarul de altitudini si cereri nu corespund cu N si M!") return False for h in altitudini: if h < 1 or h > 2**31-1: print("Valoarea unei altitudini nu respecta restrictiile problemei!") return False for q in cereri: if q < 1 or q > 2**31-1: print("Valoarea unei cereri nu respecta restrictiile problemei!") return False if len(set(cereri)) != M: print("Cererile trebuie sa fie distincte!") return False return True if __name__ == '__main__': # Validare fisier intrare if not os.access("colina.in", os.R_OK): print("Fisierul de intrare nu exista sau nu are permisiuni de citire!") exit() # Citire fisier intrare with open("colina.in", 'r') as fin: N, M = map(int, fin.readline().split()) altitudini = list(map(int, fin.readline().split())) cereri = list(map(int, fin.readline().split())) # Validare date de intrare if not validare_intrare(N, M, altitudini, cereri): exit() # Validare fisier iesire if not os.access("colina.out", os.W_OK): print("Fisierul de iesire nu poate fi creat sau nu are permisiuni de scriere!") exit() # Rezolvare problema with open("colina.out", 'w') as fout: for q in cereri: pozitii = [str(i+1) for i in range(N) if altitudini[i] == q] if pozitii: fout.write("DA " + ' '.join(pozitii) + '\n') else: fout.write("NU\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