Task: | Sanalista |
Sender: | hltk |
Submission time: | 2020-09-30 08:43:31 +0300 |
Language: | Assembly |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | 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 N 32100 section .bss ibuf resb N obuf resb N taulu resq 256 section .text global _start _start: ; read ibuf xor rax, rax xor rdi, rdi mov rsi, ibuf mov rdx, N syscall mov rsi, ibuf mov rdi, obuf ; älä sotke rdi:tä.. call stoi mov rcx, rax xor r9, r9 .s: push rcx mov rcx, taulu add rcx, 122*8 mov rax, taulu add rax, 97*8 .ss: mov qword [rax], 0 lea rax, [rax + 8] cmp rax, rcx jle .ss jmp .nxtchr_b .nxtchr_a: inc rsi .nxtchr_b: xor rax, rax lodsb cmp al, 97 jl .nxtchr_a cmp al, 122 jg .nxtchr_a .chkchr_a: inc qword [taulu + rax * 8] xor rax, rax lodsb cmp al, 97 jl .chkchr_b cmp al, 122 jg .chkchr_b jmp .chkchr_a .chkchr_b: mov rcx, taulu add rcx, 122*8 mov rax, taulu add rax, 97*8 mov r8, 1 .chkres_a: mov rbx, [rax] and rbx, 1 cmp rbx, 0 je .chkres_b mov r8, 0 .chkres_b: lea rax, [rax + 8] cmp rax, rcx jle .chkres_a add r9, r8 pop rcx dec rcx cmp rcx, 0 jg .s mov rax, r9 call printi mov rax, 0xa stosb ; 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
Verdict: ACCEPTED
input |
---|
1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 2
Verdict: ACCEPTED
input |
---|
1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
correct output |
---|
42 |
user output |
---|
42 |
Test 3
Verdict: ACCEPTED
input |
---|
1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
correct output |
---|
70 |
user output |
---|
70 |