Submission #39629872
Source Code Expand
N,M = gets.split.map(&:to_i)
R = [nil]*(N+1)
B = [nil]*(N+1)
RB = {?R=>R,?B=>B}
M.times{
a1,b1,a2,b2 = gets.split
a1,a2 = a1.to_i,a2.to_i
RB[b1][a1] = a2
RB[b2][a2] = a1
}
c = l = 0
Done = [nil]*(N+1)
ToR = lambda{|i| Done[i] ||= R[i] && ToR[R[i]] || i }
ToB = lambda{|i| Done[i] ||= B[i] && ToB[B[i]] || i }
(1..N).each{|i|
Done[i] and next or Done[i] = i
r = R[i] && ToR[R[i]]
b = B[i] && ToB[B[i]]
if r==i&&b==i
c += 1
else
l += 1
end
}
puts "#{c} #{l}"
Submission Info
| Submission Time | |
|---|---|
| Task | D - Tying Rope |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 0 |
| Code Size | 502 Byte |
| Status | TLE |
| Exec Time | 2253 ms |
| Memory | 1298816 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||
| Status | AC |
|
| Set Name | Test Cases |
|---|---|
| Sample | |
| All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | AC | 63 ms | 14116 KiB |
| sample01.txt | AC | 56 ms | 14212 KiB |
| sample02.txt | TLE | 2251 ms | 1295984 KiB |
| testcase00.txt | TLE | 2253 ms | 1293968 KiB |
| testcase01.txt | TLE | 2253 ms | 1293836 KiB |
| testcase02.txt | AC | 83 ms | 18880 KiB |
| testcase03.txt | AC | 280 ms | 18712 KiB |
| testcase04.txt | TLE | 2251 ms | 1297040 KiB |
| testcase05.txt | TLE | 2252 ms | 1296476 KiB |
| testcase06.txt | TLE | 2252 ms | 1296648 KiB |
| testcase07.txt | TLE | 2251 ms | 1298160 KiB |
| testcase08.txt | TLE | 2252 ms | 1298172 KiB |
| testcase09.txt | TLE | 2250 ms | 1293648 KiB |
| testcase10.txt | TLE | 2252 ms | 1293840 KiB |
| testcase11.txt | TLE | 2252 ms | 1293424 KiB |
| testcase12.txt | TLE | 2250 ms | 1296424 KiB |
| testcase13.txt | TLE | 2252 ms | 1296592 KiB |
| testcase14.txt | TLE | 2251 ms | 1293780 KiB |
| testcase15.txt | TLE | 2252 ms | 1293704 KiB |
| testcase16.txt | TLE | 2252 ms | 1293692 KiB |
| testcase17.txt | TLE | 2251 ms | 1297548 KiB |
| testcase18.txt | TLE | 2252 ms | 1297972 KiB |
| testcase19.txt | TLE | 2250 ms | 1293532 KiB |
| testcase20.txt | TLE | 2252 ms | 1293640 KiB |
| testcase21.txt | TLE | 2250 ms | 1293412 KiB |
| testcase22.txt | TLE | 2252 ms | 1297988 KiB |
| testcase23.txt | AC | 168 ms | 16560 KiB |
| testcase24.txt | TLE | 2252 ms | 1293704 KiB |
| testcase25.txt | TLE | 2252 ms | 1293620 KiB |
| testcase26.txt | TLE | 2250 ms | 1293740 KiB |
| testcase27.txt | TLE | 2251 ms | 1298816 KiB |