• PAT——1073. 多选题常见计分法(20)


    批改多选题是比较麻烦的事情,有很多不同的计分方法。有一种最常见的计分方法是:如果考生选择了部分正确选项,并且没有选择任何错误选项,则得到50%分数;如果考生选择了任何一个错误的选项,则不能得分。本题就请你写个程序帮助老师批改多选题,并且指出哪道题的哪个选项错的人最多。

    输入格式:

    输入在第一行给出两个正整数N(<=1000)和M(<=100),分别是学生人数和多选题的个数。随后M行,每行顺次给出一道题的满分值(不超过5的正整数)、选项个数(不少于2且不超过5的正整数)、正确选项个数(不超过选项个数的正整数)、所有正确选项。注意每题的选项从小写英文字母a开始顺次排列。各项间以1个空格分隔。最后N行,每行给出一个学生的答题情况,其每题答案格式为“(选中的选项个数 选项1 ……)”,按题目顺序给出。注意:题目保证学生的答题情况是合法的,即不存在选中的选项数超过实际选项数的情况。

    输出格式:

    按照输入的顺序给出每个学生的得分,每个分数占一行,输出小数点后1位。最后输出错得最多的题目选项的信息,格式为:“错误次数 题目编号(题目按照输入的顺序从1开始编号)-选项号”。如果有并列,则每行一个选项,按题目编号递增顺序输出;再并列则按选项号递增顺序输出。行首尾不得有多余空格。如果所有题目都没有人错,则在最后一行输出“Too simple”。

    输入样例1:

    3 4 
    3 4 2 a c
    2 5 1 b
    5 3 2 b c
    1 5 4 a b d e
    (2 a c) (3 b d e) (2 a c) (3 a b e)
    (2 a c) (1 b) (2 a b) (4 a b d e)
    (2 b d) (1 e) (1 c) (4 a b c d)
    

    输出样例1:

    3.5
    6.0
    2.5
    2 2-e
    2 3-a
    2 3-b
    

    输入样例2:

    2 2 
    3 4 2 a c
    2 5 1 b
    (2 a c) (1 b)
    (2 a c) (1 b)
    

    输出样例2:

    5.0
    5.0
    Too simple

      1 package com.hone.basical;
      2 
      3 import java.util.Scanner;
      4 /**
      5  * 原题目:https://www.patest.cn/contests/pat-b-practise/1069
      6  * @author Xia
      7  * 多选题目的计算方法
      8  * 思维陷入了僵局:实际上完全没有必要用正则表达式一一解析字符串,只需要控制好读取即可
      9  * 可以依次的读取,依次的获取需要的值
     10  * 难点:正则表达式实现,括号的匹配
     11  * 可惜有一个四分的点运行超时!!!
     12  */
     13 
     14 public class basicalLevel1073MultipleChoiceCount {
     15 
     16     public static void main(String[] args) {
     17         Scanner in = new Scanner(System.in);
     18         int n = in.nextInt();            //students numbers
     19         int m = in.nextInt();            //test numbers
     20         problem[] pArr = new problem[105];            //建立所有问题的数组
     21         int[][] wrong = new int[101][5];
     22         int max= -1;                //记录错误最多的次数
     23         
     24         for (int i = 0; i < m; i++) {
     25             problem p = new problem();
     26             p.score = in.nextInt();
     27             p.optionNum = in.nextInt();
     28             p.rightNum = in.nextInt();
     29             p.rightAns = "";
     30             for (int j = 0; j < p.rightNum; j++) {
     31                 p.rightAns += in.next();
     32             }
     33             pArr[i] = p;
     34         }
     35         
     36         
     37         for (int i = 0; i < n; i++) {
     38             double score = 0;
     39             for (int j = 0; j < m; j++) {
     40                 
     41                 int flag = 1;                //用于判断是否全对
     42                 String miss = in.next();
     43                 int k = miss.charAt(1)-'0';
     44                 String personAns = "";
     45                 for (int k2 = 0 ; k2 < k-1; k2++) {
     46                     personAns += in.next();    
     47                 }
     48                 personAns += in.next().charAt(0);
     49                 if (personAns.equals(pArr[j].rightAns)) {    //答案全部相同
     50                     score += pArr[j].score;    
     51                 }else {            //统计没有全对的情况
     52                                 //错误情况
     53                     int l = 0;
     54                     for (l = 0; l < personAns.length(); l++) {
     55                         if (pArr[j].rightAns.contains(personAns.substring(l, l+1))==false) {
     56                             flag = 0;
     57                             wrong[j][personAns.charAt(l)-'a']++;
     58                             if (wrong[j][personAns.charAt(l)-'a']>max) {
     59                                 max = wrong[j][personAns.charAt(l)-'a'];
     60                             }
     61                         }
     62                     }
     63                     //计算缺失的选项,也就是半对情况
     64                     int l2 = 0;
     65                     for (l2 = 0; l2 < pArr[j].rightAns.length(); l2++) {
     66                         if (personAns.contains(pArr[j].rightAns.substring(l2, l2+1))==false) {
     67                             wrong[j][pArr[j].rightAns.charAt(l2)-'a']++;
     68                             if (wrong[j][pArr[j].rightAns.charAt(l2)-'a']>max) {
     69                                 max = wrong[j][pArr[j].rightAns.charAt(l2)-'a'];
     70                             }
     71                         }
     72                     }
     73                     
     74                     if (flag == 1) {
     75                         score += pArr[j].score/2.0;
     76                     }
     77                 }
     78             }
     79             System.out.printf("%.1f
    ", score);
     80         }
     81         if (max == -1) {
     82             System.out.println("Too simple");
     83         }else {
     84             for (int o = 0; o < m; o++) {
     85                 for (int o2 = 0; o2 < 5; o2++) {
     86                     if (wrong[o][o2]==max) {
     87                         System.out.printf("%d %d-%c
    ", max,o+1,o2+'a');
     88                     }
     89                 }
     90             }
     91         }
     92     }
     93 }
     94 
     95 class problem{
     96     int score;
     97     int optionNum;
     98     int rightNum;
     99     String rightAns;
    100 }





  • 相关阅读:
    ASIHTTPRequest系列(一):同步和异步请求
    浅谈SQL Server2005的几种分页方法
    在iphone越狱机器中使用Hook
    iphone4 双击Home键 截获
    xcode中打印毫秒时间
    获得一个不错的电子书翻页效果,和大家分享
    【转】iOS平台XML解析类库对比和安装说明
    xml的sax解析方法
    svn 日常使用技巧以及vim profile的配置
    自制固件iOS4.1刷机、解锁教程
  • 原文地址:https://www.cnblogs.com/xiaxj/p/8005916.html
Copyright © 2020-2023  润新知