#include "testlib.h"
#include <string>
#include <cctype>

using namespace std;

// 标准答案（43 个字符，A=√，B=×；选择题为选项字母）
const char* STD_ANS = "DDCDACABADCCBCBAABCBCAABBBDABBACCCDBACCBDAA";
const int N = 43;

// 每题分值（按题号 1~43 顺序）
const double SCORES[N] = {
    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 1-15
    1, 1.5, 1.5,                    // 16-18
    3,3,3,                          // 19-21
    1.5,1.5,1.5,                    // 22-24
    3,3,3,                          // 25-27
    1.5,1.5,1.5,                    // 28-30
    3,3,3,                          // 31-33
    3,3,3,3,3,                      // 34-38
    3,3,3,3,3                       // 39-43
};

int main(int argc, char* argv[]) {
    setName("Special Judge for CSP-J 2026 笔试自测");
    registerTestlibCmd(argc, argv);

    // 读取选手输出中的所有 token，拼接成一个字符串
    string s;
    while (!ouf.seekEof()) {
        s += ouf.readToken();
    }

    // 提取所有字母并转为大写
    string ans_str;
    int i;
    for (i = 0; i < (int)s.length(); i++) {
        char c = s[i];
        if (isalpha((unsigned char)c)) {
            ans_str += (char)toupper((unsigned char)c);
        }
    }

    // 必须恰好 43 个字母
    if ((int)ans_str.length() != N) {
        quitf(_wa, "Expected %d letters, but found %d letters.", N, (int)ans_str.length());
    }

    // 逐题比较并累加得分
    double total_score = 0.0;
    for (i = 0; i < N; i++) {
        if (ans_str[i] == STD_ANS[i]) {
            total_score += SCORES[i];
        }
    }

    // 返回评测结果
    if (total_score >= 100.0 - 1e-9) {
        quitf(_ok, "All correct! Score: %.1f", total_score);
    } else {
        // 注意：此处直接传递 total_score（0~100），而不是比例
        quitp(total_score, "Score: %.1f / 100", total_score);
    }

    return 0;
}
