CSES - Datatähti 2017 alku - Results
Submission details
Task:Järjestys
Sender:yhyy
Submission time:2016-10-16 16:29:10 +0300
Language:Assembly
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED19
#2ACCEPTED37
#3ACCEPTED44
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.05 s2details
#3ACCEPTED0.09 s3details

Code

section .bss
syote resb 3000000
t resq 101010
tuloste resb 80000000
section .text
global _start
_start:
mov eax, 3
mov ebx, 0
mov ecx, syote
mov edx, 3000000
int 0x80
mov rsi, syote
mov rdi, tuloste
call luku
mov r15, r9
mov rax, r9
imul rax, 5
call tulosta
mov rcx, r15
mov r10, r15
xor rdx, rdx
mov r11, r15
xor r15, r15
.a:
call luku
inc rdx
mov [t+rdx*4], r9
mov rax, r11
dec rax
cmp r9, rdx
cmove r11, rax
loop .a
mov rcx, r11
mov r12, 1
.a2:
mov eax, [t+4]
cmp eax, r12d
jne .b
mov eax, [t+r12*4]
mov ebx, [t+4]
mov [t+4], eax
mov [t+r12*4], ebx
mov rax, r12
call tulosta
inc r15
.c: inc r12
cmp r12d, [t+r12*4]
je .c
cmp r12, r10
jg .lopeta
mov eax, [t+r12*4]
mov ebx, [t+4]
mov [t+4], eax
mov [t+r12*4], ebx
mov rax, r12
call tulosta
inc r15
.b:
xor rax, rax
mov eax, [t+4]
call vaihda
mov edx, [t+eax*4]
mov ebx, [t+4]
mov [t+4], edx
mov [t+eax*4], ebx
dec rcx
cmp rcx, 0
jg .a2
.lopeta:
mov rax, r10
imul rax, 5
sub rax, r15
mov rcx, rax
mov rax, 1
.i: call tulosta
loop .i
mov rdx, rdi
sub rdx, tuloste
mov rax, 4
mov rbx, 1
mov rcx, tuloste
int 0x80
mov rax, 1
mov rbx, 0
int 0x80
vaihda:
cmp rax, 2
jne .a
inc r15
call tulosta
jmp .palaa
.a:
add r15, 4
dec rax
call tulosta
dec rax
call tulosta
inc rax
call tulosta
inc rax
call tulosta
.palaa: ret
luku:
xor r9, r9
.a:
xor rax, rax
lodsb
cmp al, 0x30
jl .mm
cmp al, 0x39
jg .mm
sub al, 0x30
imul r9, 10
add r9, rax
jmp .a
.mm:
cmp r9, 0
je .a
ret
tulosta:
mov r9, rax
mov r14, rcx
mov rbx, rax
mov rax, 1
mov rcx, 0xa
.hh:
cqo
imul rcx
cmp rax, rbx
jle .hh
xor rdx, rdx
cqo
idiv rcx
mov r13, rax
mov rcx, r13
mov rax, rbx
jmp .hui
.hh2:
mov rax, rbx
mov rcx, r13
xor rdx, rdx
cqo
idiv rcx
mov rbx, rdx
add rax, 0x30
stosb
mov rax, r13
mov rcx, 10
xor rdx, rdx
cqo
idiv rcx
mov r13, rax
.hui:
cmp r13, 0
jg .hh2
mov eax, 0x20
stosb
mov rax, r9
mov rcx, r14
ret

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
10
9 3 4 7 6 5 10 2 8 1

correct output
32
10 10 9 10 9 8 7 9 4 2 1 4 5 2...

user output
50 8 7 8 9 7 6 7 8 2 2 1 2 3 3...

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
650 716 982 41 133 1000 876 92...

correct output
3984
207 207 206 207 128 127 126 12...

user output
5000 649 648 649 650 327 326 3...

Test 3

Group: 3

Verdict: ACCEPTED

input
100000
94703 47808 62366 31885 7091 8...

correct output
399956
98676 98676 98675 98676 62994 ...

user output
500000 94702 94701 94702 94703...