Chủ tịch giả nghèongài đấm hard như con contest toàn 4/4 xuống thị phàm chốn này chăng![]()

Đợi đi tí em up solution của @LmaoSuVuong lên cho thím học nhé, bác ấy ngày nào cũng giải được bài hếtNay cho bài 2k8 rating cơ àcó vẻ hay để mai nghiên cứu xem solution


cái rating này hình như chấm theo cái AC , vừa đọc dưới phần discuss thì là cop 1 bài bên codeforce rating 2k4, vừa đào mộ thì là bài 6 điểm trong contest 346rating 2873, AC 28.3%, Hard real đấy ae, ko phải giả cầy đâu, cook luôn chứ làm làm gì nữa
kiếm bài medium khác làm bù daily, câu sv này đi pv mà hỏi là nó ko muốn tuyển mình rồi![]()
![]()
yep, cái này là theo Elo rating system đó fency.cái rating này hình như chấm theo cái AC , vừa đọc dưới phần discuss thì là cop 1 bài bên codeforce rating 2k3, vừa đào mộ thì là bài 6 điểm trong contest 346, chỉ có 131/20k người giải dc![]()
![]()

để rating gần 2k9 ra doạ người tí thôi 
class Solution:
def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]:
graph = defaultdict(list)
for edge in edges:
if edge[2] != -1:
graph[edge[0]].append((edge[1], edge[2]))
graph[edge[1]].append((edge[0], edge[2]))
def dijktra(source):
visitedAt = [inf]*n
visitedAt[source] = 0
pq = []
pq.append((0, source))
while pq:
dist, vertex = heapq.heappop(pq)
if dist > visitedAt[vertex]:
continue
if vertex == destination:
return dist
for neighbor, weight in graph[vertex]:
neighborWeight = dist + weight
if neighborWeight < visitedAt[neighbor]:
visitedAt[neighbor] = neighborWeight
heapq.heappush(pq, (neighborWeight, neighbor))
return inf
ans = []
previousDistance = dijktra(source)
for i in range(len(edges)):
f,t,w = edges[i]
if w != -1:
ans.append([f, t, w])
continue
graph[f].append((t, 1))
graph[t].append((f, 1))
shortedDistance = dijktra(source)
if shortedDistance <= target and shortedDistance < previousDistance:
graph[f][-1] = (t, target - shortedDistance + 1)
graph[t][-1] = (f, target - shortedDistance + 1)
ans.append([f, t, target - shortedDistance + 1])
for j in range(i + 1, len(edges)):
f,t,w = edges[j]
if w != -1:
ans.append([f, t, w])
else:
ans.append([f,t, 2*10**9])
break
previousDistance = shortedDistance
ans.append([f,t, 1])
shortedDistance = dijktra(source)
return [] if shortedDistance != target else ans
Đúng người bảo vệ có khác mọi thứ đều easyNgon, quá easyđể rating gần 2k9 ra doạ người tí thôi
Python:class Solution: def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]: graph = defaultdict(list) for edge in edges: if edge[2] != -1: graph[edge[0]].append((edge[1], edge[2])) graph[edge[1]].append((edge[0], edge[2])) def dijktra(source): visitedAt = [inf]*n visitedAt[source] = 0 pq = [] pq.append((0, source)) while pq: dist, vertex = heapq.heappop(pq) if dist > visitedAt[vertex]: continue if vertex == destination: return dist for neighbor, weight in graph[vertex]: neighborWeight = dist + weight if neighborWeight < visitedAt[neighbor]: visitedAt[neighbor] = neighborWeight heapq.heappush(pq, (neighborWeight, neighbor)) return inf ans = [] previousDistance = dijktra(source) for i in range(len(edges)): f,t,w = edges[i] if w != -1: ans.append([f, t, w]) continue graph[f].append((t, 1)) graph[t].append((f, 1)) shortedDistance = dijktra(source) if shortedDistance <= target and shortedDistance < previousDistance: graph[f][-1] = (t, target - shortedDistance + 1) graph[t][-1] = (f, target - shortedDistance + 1) ans.append([f, t, target - shortedDistance + 1]) for j in range(i + 1, len(edges)): f,t,w = edges[j] if w != -1: ans.append([f, t, w]) else: ans.append([f,t, 2*10**9]) break previousDistance = shortedDistance ans.append([f,t, 1]) shortedDistance = dijktra(source) return [] if shortedDistance != target else ans

đúng là với ngôi sao thì ở đâu cũng là sân khấu. Rating 2k9 với rating 1k cũng ko có gì khác nhauNgon, quá easyđể rating gần 2k9 ra doạ người tí thôi
Python:class Solution: def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]: graph = defaultdict(list) for edge in edges: if edge[2] != -1: graph[edge[0]].append((edge[1], edge[2])) graph[edge[1]].append((edge[0], edge[2])) def dijktra(source): visitedAt = [inf]*n visitedAt[source] = 0 pq = [] pq.append((0, source)) while pq: dist, vertex = heapq.heappop(pq) if dist > visitedAt[vertex]: continue if vertex == destination: return dist for neighbor, weight in graph[vertex]: neighborWeight = dist + weight if neighborWeight < visitedAt[neighbor]: visitedAt[neighbor] = neighborWeight heapq.heappush(pq, (neighborWeight, neighbor)) return inf ans = [] previousDistance = dijktra(source) for i in range(len(edges)): f,t,w = edges[i] if w != -1: ans.append([f, t, w]) continue graph[f].append((t, 1)) graph[t].append((f, 1)) shortedDistance = dijktra(source) if shortedDistance <= target and shortedDistance < previousDistance: graph[f][-1] = (t, target - shortedDistance + 1) graph[t][-1] = (f, target - shortedDistance + 1) ans.append([f, t, target - shortedDistance + 1]) for j in range(i + 1, len(edges)): f,t,w = edges[j] if w != -1: ans.append([f, t, w]) else: ans.append([f,t, 2*10**9]) break previousDistance = shortedDistance ans.append([f,t, 1]) shortedDistance = dijktra(source) return [] if shortedDistance != target else ans
Bài này mình đoán đoán tí thôi rồi thấy có vẻ match với hint nên code thử xem, chứ nhìn thấy rating 2k9 sợ quá.Đúng người bảo vệ có khác mọi thứ đều easy![]()
![]()
![]()
đúng là người ngày làm chục câu, contest đều đặn khác với mấy thằng vô công rồi nghề, bài dễ lên gáy, bài khó cop sol lắmNgon, quá easyđể rating gần 2k9 ra doạ người tí thôi
Python:class Solution: def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]: graph = defaultdict(list) for edge in edges: if edge[2] != -1: graph[edge[0]].append((edge[1], edge[2])) graph[edge[1]].append((edge[0], edge[2])) def dijktra(source): visitedAt = [inf]*n visitedAt[source] = 0 pq = [] pq.append((0, source)) while pq: dist, vertex = heapq.heappop(pq) if dist > visitedAt[vertex]: continue if vertex == destination: return dist for neighbor, weight in graph[vertex]: neighborWeight = dist + weight if neighborWeight < visitedAt[neighbor]: visitedAt[neighbor] = neighborWeight heapq.heappush(pq, (neighborWeight, neighbor)) return inf ans = [] previousDistance = dijktra(source) for i in range(len(edges)): f,t,w = edges[i] if w != -1: ans.append([f, t, w]) continue graph[f].append((t, 1)) graph[t].append((f, 1)) shortedDistance = dijktra(source) if shortedDistance <= target and shortedDistance < previousDistance: graph[f][-1] = (t, target - shortedDistance + 1) graph[t][-1] = (f, target - shortedDistance + 1) ans.append([f, t, target - shortedDistance + 1]) for j in range(i + 1, len(edges)): f,t,w = edges[j] if w != -1: ans.append([f, t, w]) else: ans.append([f,t, 2*10**9]) break previousDistance = shortedDistance ans.append([f,t, 1]) shortedDistance = dijktra(source) return [] if shortedDistance != target else ans

Bài này mình đoán đoán tí thôi rồi thấy có vẻ match với hint nên code thử xem, chứ nhìn thấy rating 2k9 sợ quá.
Vẽ cái graph ra thì thấy nếu source và destination nó bị disconnect bởi các cạnh -1 thì có 2 trường hợp.
1) Nối 1 cạnh -1 vào mà nó giảm distance xuống, nghĩa là cái cạnh -1 nó contribute vô đường đi ngắn nhất.
2) Nối 1 cạnh -1 vào mà distance ko giảm xuống, nghĩa là cạnh -1 đấy nó ko contribute vô đường đi ngắn nhất.
Rồi tới bước chọn value cho các cạnh -1, nếu chọn value là 1 mà distance giảm xuống vẫn lớn hơn target thì tiếp tục tìm cạnh khác, vì 1 là số nhỏ nhất mà vẫn ko ăn thua nên bỏ qua cạnh vừa rồi.
Còn nếu chọn value là 1 mà distance giảm xuống nhỏ hơn target thì việc còn lại chỉ cần tăng cái weight lên cho nó match với target là xong, các cạnh còn lại mark là 2*10^9 để nó khỏi contribute vô kết quả.
em thấy thế là hơi ít FAANG síc phích mấy trăm k $ 1 năm tặng vài đô lẻ này k bõEm nghĩ bây giờ các thím tính xem card bao nhiêu hợp lí là vừa, mất lòng trước được lòng sau vậy, em đề nghị tính như này.
Mỗi lần @freedom.9 gạch ai thì người đó +2$, còn nếu ưng thì +1$Sinh hoạt trong thread này hơn 2 tháng từ lúc @freedom.9 join thì auto 10$. Các bác thấy ổn không, có ít quá không, em sợ đòi hỏi ít quá bác ấy tưởng mình coi thường![]()
![]()
Mình nhận cung cấp dịch vụ Clone nâng bi thuê trong f91 nhé:Em nghĩ bây giờ các thím tính xem card bao nhiêu hợp lí là vừa, mất lòng trước được lòng sau vậy, em đề nghị tính như này.
Mỗi lần @freedom.9 gạch ai thì người đó +2$, còn nếu ưng thì +1$Sinh hoạt trong thread này hơn 2 tháng từ lúc @freedom.9 join thì auto 10$. Các bác thấy ổn không, có ít quá không, em sợ đòi hỏi ít quá bác ấy tưởng mình coi thường![]()
![]()

Phát card trên voz là việc thiện sẽ khiến thí chủ nhẹ lòng và nhìn nhận sự việc tốt hơn. E dùng Viettel nhé. Thân!