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
0544 - Partial
(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"> nMAX = 200 def check_constraints(n, i, j): if not (1 <= n <= nMAX) or not (1 <= i <= n) or not (1 <= j <= n): with open("partialOUT.txt", "w") as fout: fout.write("Datele nu corespund restrictiilor impuse") return False return True def dfs(n, gf, viz, viznod): def dfs_util(nod): viznod[nod] = True for j in range(1, n + 1): if gf[nod][j] and not viznod[j]: viz[nod][j] = viz[j][nod] = True dfs_util(j) dfs_util(1) def process_input(): n, m = 0, 0 gf = [[False] * (nMAX + 1) for _ in range(nMAX + 1)] viz = [[False] * (nMAX + 1) for _ in range(nMAX + 1)] viznod = [False] * (nMAX + 1) with open("partialIN.txt", "r") as fin: n = int(fin.readline().strip()) if not check_constraints(n, 1, 1): return for line in fin: a, b = map(int, line.split()) if not check_constraints(n, a, b): return gf[a][b] = gf[b][a] = True m += 1 dfs(n, gf, viz, viznod) mfol = 0 for i in range(1, n + 1): for j in range(i + 1, n + 1): if mfol != m // 2 and gf[i][j] and not viz[i][j]: gf[i][j] = gf[j][i] = False mfol += 1 with open("partialOUT.txt", "w") as fout: if check_constraints(n, 1, 1): for i in range(1, n + 1): fout.write(' '.join(map(str, [int(x) for x in gf[i][1:n + 1]])) + '\n') if __name__ == "__main__": process_input() </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