이전 주제 보기 :: 다음 주제 보기 |
글쓴이 |
메시지 |
황호기
가입: 2013년 9월 4일 올린 글: 19
|
올려짐: 2013년11월18일 16:11 주제: 6-8 큰 테스트케이스 |
|
|
(define (makeinput n)
(if (= n 0) '()
(let ((a (string->symbol (string-append "A" (number->string n))))
(b (string->symbol (string-append "B" (number->string n))))
(c (string->symbol (string-append "C" (number->string n)))))
(append (list (cons a (mustAnd (mustItems (list -2 -1 n)) (mustHaveCommon (mustBeTheSame b) (mustBeTheSame c))))
(cons b (mustHaveCommon (mustBeTheSame c) (mustItems (list -1 n))))
(cons c (mustAnd (mustItems (list n)) (mustHaveExceptFor (mustBeTheSame a) '(-1)))))
(makeinput (- n 1))))))
(define (makeoutputA n)
(if (= n 0) '() (append (makeoutputA (- n 1)) (list (cons (string->symbol (string-append "A" (number->string n))) (list -2 -1 n))))))
(define (makeoutputB n)
(if (= n 0) '() (append (makeoutputB (- n 1)) (list (cons (string->symbol (string-append "B" (number->string n))) (list n))))))
(define (makeoutputC n)
(if (= n 0) '() (append (makeoutputC (- n 1)) (list (cons (string->symbol (string-append "C" (number->string n))) (list -2 n))))))
(define (makeoutput n)
(msort(append (makeoutputA n) (makeoutputB n) (makeoutputC n))))
(output
(lambda ()
(equal? (shoppingList
(makeinput 1000))
(makeoutput 1000))))
1000 대신에 적당히 큰 숫자를 넣어주세요. grade파일에 넣어주시면 됩니다. 몇정도에서 10초 이상 걸리나요?
그리고 생각해보니 msort가 없을텐데 msort함수는 다음과 같아요.
(define (changesymbol slist result)
(if (null? slist) result
(changesymbol (cdr slist) (append result (list (cons (string->symbol (caar slist)) (cdar slist)))))))
(define (changestring slist result)
(if (null? slist) result
(changestring (cdr slist) (append result (list (cons (symbol->string (caar slist)) (cdar slist)))))))
(define (msort slist)
(changesymbol(sort (changestring slist '()) #:key car string<?) '())) |
|
위로 |
|
|
황호기
가입: 2013년 9월 4일 올린 글: 19
|
올려짐: 2013년11월18일 16:54 주제: |
|
|
하나 더 추가합니다.
역시 grade파일에 옯기시면 되고요,역시 msort를 같이 넣어주시면 됩니다.
(define (makeinput2 n)
(if (= n 1) (list (cons 'A1 (mustItems (list 1))))
(append (list (cons (string->symbol (string-append "A" (number->string n)))
(mustAnd (mustItems (list n)) (mustBeTheSame (string->symbol (string-append "A" (number->string (- n 1))))))))
(makeinput2 (- n 1)))))
(define (makeintlist n result)
(if (= n 0) result
(makeintlist (- n 1) (append (list n) result))))
(define (makeoutput2 n)
(if (= n 0) '()
(msort(append (list (cons (string->symbol (string-append "A" (number->string n)))
(makeintlist n '())))
(makeoutput2 (- n 1))))))
(output
(lambda ()
(equal? (shoppingList
(makeinput2 1000))
(makeoutput2 1000)))) |
|
위로 |
|
|
김동욱
가입: 2013년 9월 14일 올린 글: 23
|
올려짐: 2013년11월18일 23:43 주제: ㅇㅇ |
|
|
좋은 글 감사합니다..
랩탑에서 돌렸을때 1번은
1000 -> 3s
2000 -> 13s
3000 -> 25s
이정도구요 2번은
500 -> 2s
1000 -> 15s
이러네요.. ;;
어느 집안 조카들이 천명이나 된대요.. ㅜ?ㅜ |
|
위로 |
|
|
|