Submission #3609891


Source Code Expand

Copy
N, M = gets.split.map(&:to_i)
num = Array.new(N+1){Hash.new(0)}

ans = 0
M.times do |i|
    a, b, l = gets.split.map(&:to_i)
    ans += num[a][2540-l] + num[b][2540-l]
    num[a][l] += 1
    num[b][l] += 1
end
puts ans

Submission Info

Submission Time
Task A - 2540
User betrue12
Language Ruby (2.3.3)
Score 300
Code Size 228 Byte
Status
Exec Time 280 ms
Memory 31228 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
01.txt 275 ms 31228 KB
02.txt 278 ms 12668 KB
03.txt 202 ms 2172 KB
04.txt 202 ms 2172 KB
05.txt 280 ms 31228 KB
06.txt 245 ms 17148 KB
07.txt 171 ms 31100 KB
08.txt 7 ms 1788 KB
09.txt 204 ms 2172 KB
sample_01.txt 7 ms 1788 KB
sample_02.txt 7 ms 1788 KB