Task: | Ratsun reitit |
Sender: | hltk |
Submission time: | 2020-09-30 21:53:53 +0300 |
Language: | Assembly |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 27 |
#2 | ACCEPTED | 31 |
#3 | ACCEPTED | 42 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#8 | ACCEPTED | 0.00 s | 2, 3 | details |
#9 | ACCEPTED | 0.01 s | 2, 3 | details |
#10 | ACCEPTED | 0.01 s | 2, 3 | details |
#11 | ACCEPTED | 0.01 s | 3 | details |
#12 | ACCEPTED | 0.01 s | 3 | details |
#13 | ACCEPTED | 0.01 s | 3 | details |
Code
%macro r1_push 0 ; push registers except rax push rbx push rcx push rdx push r8 push r9 push r10 push r11 %endmacro %macro r1_pop 0 ; pop registers except rax pop r11 pop r10 pop r9 pop r8 pop rdx pop rcx pop rbx %endmacro %macro r_push 0 ; push registers including rax push rax r1_push %endmacro %macro r_pop 0 ; pop registers including rax r1_pop pop rax %endmacro %define IBUFSZ 100 %define OBUFSZ 30000 %define QUEUESZ 15000 %define MAXN 100 %define DISTSZ MAXN * MAXN section .rodata ci: dq 1 dq 1 dq -1 dq -1 dq 2 dq 2 dq -2 dq -2 cj: dq 2 dq -2 dq 2 dq -2 dq 1 dq -1 dq 1 dq -1 section .bss ibuf resb IBUFSZ obuf resb OBUFSZ queuei resq QUEUESZ queuej resq QUEUESZ dist resq DISTSZ N resq 1 section .text global _start _start: xor rax, rax .floop: mov qword [dist + rax * 8], -1 inc rax cmp rax, DISTSZ jl .floop ; read ibuf xor rax, rax xor rdi, rdi mov rsi, ibuf mov rdx, IBUFSZ syscall mov rsi, ibuf mov rdi, obuf ; älä sotke rdi:tä.. call stoi mov [N], rax xor rax, rax ; head xor rbx, rbx ; tail ; while (head < tail) mov qword [queuei + rbx], 0 mov qword [queuej + rbx], 0 mov qword [dist], 0 inc rbx .bfs: mov r8, [queuei + rax * 8] mov r9, [queuej + rax * 8] imul r8, 800 imul r9, 8 mov r10, [dist + r8 + r9] inc r10 mov rdi, obuf xor rcx, rcx .cloop: mov r8, [queuei + rax * 8] mov r9, [queuej + rax * 8] add r8, [ci + rcx * 8] add r9, [cj + rcx * 8] cmp r8, 0 jl .cloopnxt cmp r9, 0 jl .cloopnxt cmp r8, [N] jge .cloopnxt cmp r9, [N] jge .cloopnxt push r8 push r9 imul r8, 800 imul r9, 8 mov r11, [dist + r8 + r9] pop r9 pop r8 cmp r11, -1 jne .cloopnxt push r8 push r9 imul r8, 800 imul r9, 8 mov [dist + r8 + r9], r10 pop r9 pop r8 mov [queuei + rbx * 8], r8 mov [queuej + rbx * 8], r9 inc rbx .cloopnxt: inc rcx cmp rcx, 8 jl .cloop inc rax cmp rax, rbx jl .bfs xor rax, rax .pl: xor rbx, rbx .pll: push rax push rbx imul rax, 800 imul rbx, 8 mov rax, [dist + rax + rbx] call printi mov rax, 0x20 stosb pop rbx pop rax inc rbx cmp rbx, [N] jl .pll push rax mov rax, 0xa stosb pop rax inc rax cmp rax, [N] jl .pl ; output obuf sub rdi, obuf mov rdx, rdi mov rdi, 1 mov rax, 1 mov rsi, obuf syscall ; exit syscall mov rax, 0x3c xor rdi, rdi syscall stoi: ; reads in integer from rsi s buffer and outputs it to rax r1_push xor r8,r8 mov r9, 1 .a_stoi: xor rax, rax lodsb cmp al, 45 jne .b_stoi mov r9, -1 jmp .a_stoi .b_stoi: cmp al, 32 je .c_stoi cmp al, 10 je .c_stoi cmp al, 0 je .c_stoi sub al, 48 mov rdx, 10 imul r8, rdx add r8, rax jmp .a_stoi .c_stoi: mov rax, r8 imul rax, r9 r1_pop ret printi: ; outputs an integer rdi s buffer push rax r1_push xor rbx, rbx cmp rax, 0 jnl .a_printi imul rax, -1 push rax mov rax, 45 stosb pop rax .a_printi: xor rdx, rdx mov rcx, 10 idiv rcx add rdx, 48 push rdx inc rbx cmp rax, 0 jne .a_printi mov rcx, rbx .b_printi: pop rax stosb loop .b_printi mov rax, rdi r1_pop mov rdi, rax pop rax ret
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
user output |
---|
0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
0 3 2 3 2 3 4 1 2 3 2 1 4 3 2 3 2 3 2 3 2 3 2 3 4 |
user output |
---|
0 3 2 3 2 3 4 1 2 3 2 1 4 3 2 3 2 3 2 3 2 3 2 3 4 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
0 3 2 3 2 3 3 4 1 2 3 4 2 1 4 3 2 3 3 2 3 2 3 4 2 3 2 3 4 3 ... |
user output |
---|
0 3 2 3 2 3 3 4 1 2 3 4 2 1 4 3 2 3 3 2 3 2 3 4 2 3 2 3 4 3 ... |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
0 3 2 3 2 3 4 3 4 1 2 3 4 3 2 1 4 3 2 3 4 3 2 3 2 3 4 3 2 3 2 3 4 3 4 ... |
user output |
---|
0 3 2 3 2 3 4 3 4 1 2 3 4 3 2 1 4 3 2 3 4 3 2 3 2 3 4 3 2 3 2 3 4 3 4 ... Truncated |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
0 3 2 3 2 3 4 5 3 4 1 2 3 4 3 4 2 1 4 3 2 3 4 5 3 2 3 2 3 4 3 4 2 3 2 3 4 3 4 5 ... |
user output |
---|
0 3 2 3 2 3 4 5 3 4 1 2 3 4 3 4 2 1 4 3 2 3 4 5 3 2 3 2 3 4 3 4 2 3 2 3 4 3 4 5 ... Truncated |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
0 3 2 3 2 3 4 5 4 3 4 1 2 3 4 3 4 5 2 1 4 3 2 3 4 5 4 3 2 3 2 3 4 3 4 5 2 3 2 3 4 3 4 5 4 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 3 4 1 2 3 4 3 4 5 2 1 4 3 2 3 4 5 4 3 2 3 2 3 4 3 4 5 2 3 2 3 4 3 4 ... Truncated |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 3 4 1 2 3 4 3 4 5 6 2 1 4 3 2 3 4 5 4 5 3 2 3 2 3 4 3 4 5 6 2 3 2 3 4 3 4 5 4 5 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 3 4 1 2 3 4 3 4 5 6 2 1 4 3 2 3 4 5 4 5 3 2 3 2 3 4 3 4 5 6 2 3 2 ... Truncated |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
25 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
49 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 10
Group: 2, 3
Verdict: ACCEPTED
input |
---|
50 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
75 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
99 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
100 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |