---
# System prepended metadata

title: CP1 HW04 評分標準
tags: ["CP1\_", HW04]

---

# HW04 評分標準


## 4.1 Sorting

共有 10 筆測試，mysort 的部分 8 筆，myprint 的部分 2 筆。每筆 2 分，共 20 分。
各別超時時限 30 秒。

* 01-sort-simple：正奇偶數排序
* 02-sort-empty：長度 0 空陣列（合法陣列下界）
* 03-sort-odd：只有正奇數
* 04-sort-even：只有正偶數
* 05-sort-negative：負數排序
* 06-sort-mixed：正負數混合排序
* 07-sort-large-array：陣列長 100000
* 08-sort-large-number：int32 整數邊界
* 09-print-unordered：印數字（是否在 myprint 中多做排序）
* 10-print-ordered：印數字

助教的 hw0401.c：https://github.com/JacobLinCool/cpta/blob/main/examples/2023-fall/hw0401/.build/mount/hw0401.c

詳細測試資料可參考：https://github.com/JacobLinCool/cpta/tree/main/examples/2023-fall/hw0401/.cases

## 4.2 Differential of a Function
- 有放寬條件批改，只要輸出的多項式是等價的形式就會算對，前提是格式需符合題目要求

2.5pts for each case

:::spoiler Case1
```
2
1 0 1
2
1 0 0
```
:::

:::spoiler Case2
```
5
1 5 3 2 1 2
4
2 4 -1 3 3
```
:::

:::spoiler Case3
```
1
1 0
2
-1 -3523 323
```
:::

:::spoiler Case4
```
4
-2342341 0 0 2 0
4
-1233 0 1 -123 0
```
:::

:::spoiler Case5
```
0
0
0
0
```
:::

:::spoiler Case6
```
0
-2147483648
0
-2147483648
```
:::

:::spoiler Case7
```
10
[32487324] * 11
10
[32487324] * 11
```
:::

:::spoiler Case8
```
10
[47839] * 11
10
[-29843] * 11
```
:::

## 4.3 GSAT

正解及測試資料檔案：
https://drive.google.com/file/d/1PMJzUOmO7D7DljvlnDVE77xjfVmVie-R/view?usp=sharing

只會放入 gsat.h 一次，並根據其結果給分。
學生數量為 1000 人，可能包含 0 級分（aka 原始分數 0 分）
預設 20 分，若錯一格 -1，直到 0 分為止。

有些人剛好錯 2 個而得到 18 分，請再參考一次學測級分計算的維基百科。
輸出內容必須與題目上相符，並且只能以 `/t` 或 ` ` (空格) 符號分隔。

這應該是所有題目裡平均得分最高的題目了，如果有問題歡迎寄信詢問。

## 4.4 Xiangqi

:::spoiler hw0404.c(測資檔)
```c
#include "mychess.h"
#include <stdio.h>
#include <stdlib.h>

// SOLDIER: 3 pts
// (3, 3) -> (6, 4),(7, 3) ,(兵不能後退)
int board1[10][9] = {
{0,0,0,0,RED_GENERAL,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,RED_SOLDIER,0,0,0,0,0},
{0,0,0,BLACK_ADVISOR,BLACK_GENERAL,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,RED_SOLDIER,0,0,0,0}
};

// HORSE: 4 pts
// (6, 1) -> (8, 2) (拐馬腳)
// (7, 8) -> (8, 6)
// 排序: 1 pts
int board2[10][9] = {
{0,0,0,0,RED_GENERAL,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,RED_HORSE,BLACK_SOLDIER,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,RED_HORSE},
{0,0,0,0,0,0,BLACK_CHARIOT,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// MISC: 6 pts
// CHARIOT: (6, 2) -> (6, 4), (9, 2) 2 pts
// CANNON: (3, 6) -> (3, 4), (9, 6) 2 pts
// 不同種(CHARIOT, CANNON) 排序 1 pts
// 同種排序: 1 pts
int board3[10][9] = {
{0,0,0,0,RED_GENERAL,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,RED_CANNON,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_SOLDIER,0,0,0,0},
{0,0,RED_CHARIOT,0,0,0,BLACK_SOLDIER,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,BLACK_ELEPHANT,0,BLACK_GENERAL,BLACK_ADVISOR,BLACK_ELEPHANT,0,0}
};

// GENERAL: 1 pts
// (0, 3) -> (0, 4)
int board4[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 兵在我方倒退 1 pts
int board5[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,RED_SOLDIER,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 兵在我方向左 1 pts
int board6[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,RED_SOLDIER,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 象在不對的位置 1 pts
int board7[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,RED_ELEPHANT,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 象過河 1 pts
int board8[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,RED_ADVISOR,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{RED_ELEPHANT,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 士沒斜走 1 pts
int board9[10][9] = {
{0,0,0,RED_GENERAL,0,0,0,0,0},
{0,0,0,0,RED_ADVISOR,RED_ADVISOR,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

// Invalid case: 將超出範圍 1 pts
int board10[10][9] = {
{0,0,0,0,RED_GENERAL,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,RED_SOLDIER,0,0,0,0,0,0,0},
{0,0,BLACK_GENERAL,0,0,0,0,0,0}
};

// Invalid case: 多一顆 1 pts
int board11[10][9] = {
{0,0,0,0,RED_GENERAL,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{RED_SOLDIER,0,RED_SOLDIER,0,RED_SOLDIER,0,RED_SOLDIER,0,RED_SOLDIER},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,RED_SOLDIER,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,BLACK_GENERAL,0,0,0,0}
};

int total = 0;
int log_index = 0;
int score_log[11] = {0,0,0,0,0,0,0,0,0,0,0};

void enter_score(){
    printf("Enter score: ");
    int score;
    scanf("%d", &score);
    total += score;
    score_log[log_index] = score;
    log_index += 1;
    system("clear");
}

int main(){
    // 編號未重編 - 1 pts
    printf("--------- board1 3 pts---------\n");
    printf("Correct answer: \n");
    printf("1) Move Soldier from (6,3) to (6,4)\n");
    printf("2) Move Soldier from (6,3) to (7,3)\n");
    printf("3) 兵不能後退(前面要答對一個)(9,4)->(8,4)\n");
    printf("Your answer: \n");
    checkmate(board1);
    enter_score();
    printf("--------- board2 4 pts---------\n");
    printf("Correct answer: \n");
    printf("1) Move Horse from (6,1) to (8,2)\n");
    printf("2) Move Horse from (7,8) to (8,6)\n");
    printf("3) 拐馬腳(6,1) to (7,3)\n");
    printf("4) 排序(1,2 都要對)\n");
    printf("Your answer: \n");
    checkmate(board2);
    enter_score();
    printf("--------- board3 6 pts---------\n");
    printf("Correct answer: \n");
    printf("1) Move Chariot from (6,2) to (6,4)\n\
2) Move Chariot from (6,2) to (9,2)\n\
3) Move Cannon from (3,6) to (3,4)\n\
4) Move Cannon from (3,6) to (9,6)\n");
    printf("5) 不同種(CHARIOT, CANNON) 排序\n");
    printf("6) 同種排序(1&2 或 3&4)\n");
    printf("Your answer: \n");
    checkmate(board3);
    enter_score();
    printf("--------- board4 1 pts---------\n");
    printf("Correct answer: \n");
    printf("1) Move General from (0,3) to (0,4)\n");
    printf("Your answer: \n");
    checkmate(board4);
    enter_score();
    int error_score = 0;
    int error[7] = {1,1,1,1,1,1,1};
    if(checkmate(board5) == -1){
        score_log[4] = 1;
        error_score += 1;
    }
    if(checkmate(board6) == -1){
        score_log[5] = 1;
        error_score += 1;
    }
    if(checkmate(board7) == -1){
        score_log[6] = 1;
        error_score += 1;
    }
    if(checkmate(board8) == -1){
        score_log[7] = 1;
        error_score += 1;
    }
    if(checkmate(board9) == -1){
        score_log[8] = 1;
        error_score += 1;
    }
    if(checkmate(board10) == -1){
        score_log[9] = 1;
        error_score += 1;
    }
    if(checkmate(board10) == -1){
        score_log[10] = 1;
        error_score += 1;
    }

    int nosort = 0;
    printf("編號有重編: ");
    scanf("%d", &nosort);

    printf("<p>--------- score ---------</p>\n");
    printf("<p>Normal score: %d</p>\n", total);
    printf("<p>Error score: %d</p>\n", error_score);
    printf("<p>編號: %d</p>\n", nosort);
    printf("<p>Total score: %d</p>\n", total + error_score + nosort);
    printf("<p>--------- score log ---------</p>\n");
    printf("<p>");
    for(int i = 0; i < 11; i++){
        printf("%d ", score_log[i]);
    }
    printf("</p>\n");
    enter_score();
    return 0;
}

```
:::

因為題目有要求你們要提供 `mychess.h`，所以必須要提供題目上要求的 header file(包含 function 和 #define)。
### 正常測資 14 pts
盤面編號: board1 ~ board4

#### 整體扣分項目
1. 若多輸出一個答案扣 1 分，直到該盤面分數扣完為止
2. 若沒編號或新盤面沒重新編號: -1 pt

#### board1 3 pts
board1 正確答案 2 pts:
```
1) Move Soldier from (6,3) to (6,4) (1 pt)
2) Move Soldier from (6,3) to (7,3) (1 pt)
```
不能輸出以下答案，因為兵不能後退 1 pt:
```
3) Move Soldier from (9,4) to (8,4)
```
但這個分數必須正確答案(1,2)答對至少一個才能拿到。

#### board2 4 pts
board2 正確答案 2 pts:
```
1) Move Horse from (6,1) to (8,2) (1 pt)
2) Move Horse from (7,8) to (8,6) (1 pt)
```
不能輸出以下答案，因為拐馬腳 1 pt:
```
Move Horse from (6,1) to (7,3)
```
排序 1 pt:
- 且必須正確答案(1,2)都答對才會給分

#### board3 6 pts

board3 正確答案 4 pts:
```
1) Move Chariot from (6,2) to (6,4) (1 pt)
2) Move Chariot from (6,2) to (9,2) (1 pt)
3) Move Cannon from (3,6) to (3,4) (1 pt)
4) Move Cannon from (3,6) to (9,6) (1 pt)
```

同顆棋子排序 1 pt: 
- 1,2 或是 3,4 的順序不能反過來
- 必須符合 1,2 都答對或 3,4 都答對才會給分

不同種棋子排序 1 pt:
- Chariot 要在 Cannon 前面

#### board4 1 pts

board4 正確答案 1 pts:
```
1) Move General from (0,3) to (0,4) (1 pt)
```

### 錯誤測資 7 pts
盤面編號: board5 ~ board11

需回傳 -1 才算正確

**若你很幸運的拿到 21 分(14+7)，那你會很不幸的拿到 20 分**

## 4.5 Japanese Mahjong
- 二盃口在 Yaku.pdf 有標示錯誤，因此如果你寫 2 番或是 3 番我都會算做正確。
- 能辨識是哪種役，小錯字不會扣分(少s、沒大寫)，但用其他命名的我不會給分，我看不懂啊...（我有給你們 Yaku.pdf 餒...） 
- 28 種役正確且番數正確（多輸出倒扣）：各 0.5 分 (14分)
- Total 番數正確：各 0.3 分 (3分)
- 能看出有從大到小排序： 1 分
- 阻擋錯誤輸入： 各 0.5 分 (2分)

:::spoiler Case1
```
32 32 32 32 0
0
33 33 33 33 0
0
28 28 28 28 0
0
1 1 1 0
1
34 34
34
0
0

```
```
The Score is...
    All terminals and honors (2 Han)
    All triplets (2 Han)
    Half-flush (2 Han)
    Little three dragons (2 Han)
    Three concealed triplets (2 Han)
    Three Kans (2 Han)
    Honer: Green (1 Han)
    Honer: Player's wind (1 Han)
    Honer: Prevailing wind (1 Han)
    Honer: White (1 Han)
Total: 16 Han (Kazoe-yakuman)
```
:::
:::spoiler Case2
```
2 2 3 3 11 11 12 12 20 20 21 21 22 22 0
22
0
0
```
```
The score is...
    Seven pairs (2 Han)
    All simples (1 Han)
Total: 3 Han
```
:::
:::spoiler Case3
```
1 2 3 0
0
4 5 6 0
0
7 8 9 0
0
1 2 3 0
0
9 9
1
0
0
```
```
The score is...
    Flush (6 Han)
    Straight (2 Han)
    No-points hand (1 Han)
    One set of identical sequences (1 Han)
Total: 10 Han
```
:::
:::spoiler Case4
```
1 2 3 0
1
10 11 12 0
1
19 20 21 0
1
31 31 31 0
1
32 32
32
0
0
```
```
```
:::
:::spoiler Case5
```
7 8 9 0
0
7 8 9 0
0
16 17 18 0
0
16 17 18 0
0
19 19
19
0
0
```
```
The score is...
    Terminal or honor in each set (1 Han)
    Three colour straights (1 Han)
Total: 2 Han
```
:::
:::spoiler Case6
```
5 5 5 0
1
14 14 14 0
1
23 23 23 0
1
1 2 3 0
0
9 9
9
0
0
```
```
The score is...
    Three colour triplets (2 Han)
Total: 2 Han

```
:::
:::spoiler Case7
```
28 28 28 28 0
0
29 29 29 29 0
0
30 30 30 30 0
0
31 31 31 31 0
0
32 32
32
0
0
```
```
The score is...
    Big four winds (2 Yakuman)
    Four concealed triplets single wait (2 Yakuman)
    All honors (1 Yakuman)
    Four kans (1 Yakuman)
Total: 6 Yakuman

```
:::
:::spoiler Case8
```
1 9 32 10 18 19 27 29 30 31 33 34 28 1 0
1
0
0
```
```
The Score is...
    Thirteen orphans 13 wait (2 Yakuman)
Total: 2 Yakuman
```
:::
:::spoiler Case9
```
1 1 1 0
0
2 3 4 0
0
6 7 8 0
0
9 9 9 0
0
5 5
5
0
0
```
```
The Score is...
    Nine gates nine wait (2 Yakuman)
Total: 2 Yakuman
```
:::
:::spoiler Case10
```
11 11 11 0
1
12 12 12 0
1
13 13 13 0
1
15 15 15 0
1
17 17
17
0
0
```
```
The Score is...
    All green (1 Yakuman)
Total: 1 Yakuman
```
:::
:::spoiler Case11
```
1 1 1 1 0
0
1 1 1 1 0
0
2 2 2 2 0
1
3 3 3 3 0
1
4 4
4
0
0
```
```
The Score is... 
    Unreasonable case 
Total: 0 Han
```
:::
:::spoiler Case12
```
-100 -111 -112 0
0
1 1 1 0
0
2 2 2 0
0
3 3 3 0
0
4 4 
4
0
0
```
```
The Score is... 
    Unreasonable case 
Total: 0 Han
```
:::

:::spoiler Case13
```
1 3 4 0
0
5 5 5 0
0
6 6 6 0
0
7 7 7 0
0
8 8
8
0
0
```
```
The Score is... 
    Unreasonable case 
Total: 0 Han
```
:::

:::spoiler Case14
```
1 2 3 0
0
13 14 15 0
1
25 26 27 0
1
4 4 4 0
1
5 5
5
0
0
```
```
The Score is... 
    No Yaku
Total: 0 Han
```
:::





## 4.6 What Happens?

Stack Overflow!
