Submission #7605608


Source Code Expand

parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;r;end

function sim(e::Array{Array{Array{Int,1},1},1},x::Int)
	now = x
	num = 0
	while 1==1
		k = bsearch(e[now][1],num+1)
		if k>length(e[now][1])
			break
		else
			num = e[now][1][k]
			now = e[now][2][k]
		end
	end
	now
end

function main()
	n,m,d = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	e = [[Int[],Int[]] for i in 1:n]
	for i in 1:m
		push!(e[a[i]][1], i)
		push!(e[a[i]][2], a[i]+1)
		push!(e[a[i]+1][1], i)
		push!(e[a[i]+1][2], a[i])
	end
	r = 0
	while 2^r<=d
		r += 1
	end
	dp = zeros(Int,r,n)
	for i in 1:n
		dp[1,i] = sim(e,i)
	end
	for i in 2:r
		for j in 1:n
			dp[i,j] = dp[i-1,dp[i-1,j]]
		end
	end
	s = parseMap(split(bin(d,2),""))
	l = length(s)
	for i in 1:n
		now = i
		for j in 0:l-1
			if s[l-j]==1
				now = dp[j+1,now]
			end
		end
		println(now)
	end
end

main()

Submission Info

Submission Time
Task D - 阿弥陀
User T49E2
Language Julia (0.5.0)
Score 100
Code Size 1049 Byte
Status AC
Exec Time 856 ms
Memory 200244 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 712 ms 172676 KB
01_random01.txt AC 473 ms 113284 KB
01_random02.txt AC 474 ms 112132 KB
01_random03.txt AC 473 ms 111752 KB
01_random04.txt AC 479 ms 115040 KB
01_random05.txt AC 615 ms 155072 KB
01_random06.txt AC 696 ms 173696 KB
01_random07.txt AC 806 ms 172672 KB
02_i.txt AC 475 ms 115436 KB
02_p.txt AC 478 ms 116292 KB
02_random01.txt AC 478 ms 114100 KB
02_random02.txt AC 476 ms 111876 KB
02_random03.txt AC 477 ms 113524 KB
02_random04.txt AC 474 ms 115836 KB
02_random05.txt AC 485 ms 117944 KB
02_random06.txt AC 523 ms 126472 KB
02_random07.txt AC 575 ms 144092 KB
02_random08.txt AC 580 ms 142144 KB
02_rp01.txt AC 476 ms 115048 KB
02_rp02.txt AC 476 ms 113824 KB
02_rp03.txt AC 475 ms 114740 KB
02_rp04.txt AC 476 ms 115944 KB
02_rp05.txt AC 481 ms 114336 KB
03_i.txt AC 480 ms 115148 KB
03_random01.txt AC 481 ms 115968 KB
03_random02.txt AC 552 ms 136708 KB
03_random03.txt AC 536 ms 134268 KB
03_random04.txt AC 549 ms 133888 KB
03_random05.txt AC 487 ms 118528 KB
03_random06.txt AC 491 ms 116180 KB
03_random07.txt AC 494 ms 120032 KB
03_random08.txt AC 480 ms 116828 KB
03_random09.txt AC 500 ms 123124 KB
03_random10.txt AC 522 ms 128640 KB
03_random11.txt AC 552 ms 135840 KB
03_random12.txt AC 558 ms 137388 KB
03_random13.txt AC 543 ms 133572 KB
03_random14.txt AC 530 ms 131248 KB
03_random15.txt AC 497 ms 120796 KB
04_i.txt AC 846 ms 194996 KB
04_p1.txt AC 749 ms 189180 KB
04_p2.txt AC 653 ms 174488 KB
04_random01.txt AC 652 ms 162536 KB
04_random02.txt AC 547 ms 149824 KB
04_random03.txt AC 530 ms 136720 KB
04_random04.txt AC 566 ms 147708 KB
04_random05.txt AC 559 ms 148776 KB
04_random06.txt AC 645 ms 162976 KB
04_random07.txt AC 677 ms 165244 KB
04_random08.txt AC 644 ms 154604 KB
04_random09.txt AC 646 ms 155976 KB
04_random10.txt AC 629 ms 157932 KB
04_random11.txt AC 856 ms 198912 KB
04_random12.txt AC 842 ms 200244 KB
04_random13.txt AC 832 ms 198492 KB
04_rp01.txt AC 765 ms 187792 KB
04_rp02.txt AC 770 ms 189000 KB
04_rp03.txt AC 750 ms 192172 KB
04_rp04.txt AC 746 ms 188156 KB
04_rp05.txt AC 754 ms 187916 KB
04_rp06.txt AC 756 ms 187296 KB
04_rp07.txt AC 747 ms 187128 KB
04_rp08.txt AC 754 ms 187816 KB
04_rp09.txt AC 760 ms 189432 KB
04_rp10.txt AC 767 ms 190600 KB
sample_1.txt AC 474 ms 120872 KB
sample_2.txt AC 473 ms 112544 KB
sample_3.txt AC 473 ms 114508 KB