선택 1058 (20 분)

선택 1058 (20 분)

여러 선택을 표시하는 것은 더 귀찮은 일이,이 질문은 도움이 교사는 객관식 질문을 표시하는 프로그램을 작성하도록 요청하고, 무엇을 대부분의 사람들에게 잘못된 질문을 지적합니다.

입력 형식 :

첫 행 및 M (≤ 100)로 입력 주어진 두 양의 정수 N (≤ 1000) 각각 학생수 및 객관식 문제의 수. 다음에 M 개의 행은 각 행에 순차적으로 (하게는 5 이하의 양의 정수) 질문에서 옵션의 숫자 값을 부여한다 (양의 정수를 적어도 2 이상, 5), 옵션의 정확한 개수 (옵션은 초과하지 양의 정수), 모든 올바른 옵션을 제공합니다. 참고 소문자에서 각 질문에 대한 옵션은 순차적 인 배열을 시작하는 것이다. 중에서도 공간으로 분리된다. 마지막 N 라인, 각 학생은 대답 경우, 각 질문에 응답 형식으로 주어진 (选中的选项个数 选项1 ……)순서에 주어진 제목을. 참고 : 제목 보장 학생들의 경우 합법적 인 대답 옵션의 실제 수보다 존재하지 않는 선택 옵션의 수.

출력 형식 :

각 학생은 입력 순서, 줄에 각 점수에 따라 점수가 부여됩니다. 만 참고 문장 질문의 점수를 얻기 위해 모든 적절한 질문을 선택합니다. 출력 항목 중 가장 잘못된 오류의 수와 (1 번째의 타이틀 입력의 순서대로) 번호의 마지막 라인. 옆 측이 경우, 출력 순서를 오름차순으로 번호를 누른다. 번호는 공백으로 구분 사이에, 처음부터 끝까지 선은 여분의 공간이 없을 수 있습니다. 모든 주제 만약 아무 잘못, 마지막 줄에 출력 Too simple.하지

샘플 입력 :

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) (2 b d) (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) (2 b c) (4 a b c d)


      
    

샘플 출력 :

3
6
5
2 2 3 4

방법 1 :

#include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;

struct student
{
   int no; //编号
   int score ;
   int num;
   int right; //正确选项个数
   int p1; //错误次数
   set<char> option;
};

int main()
{
    int N, M;
    cin >> N >> M;
    struct student stu[M];
    for(int i = 0; i < M; i++){
        cin >> stu[i].score >> stu[i].num >> stu[i].right ;
        stu[i].no = i + 1;
        stu[i].p1 = 0;
        for(int  j = 0; j < stu[i].right; j++){
            char ch;
            scanf(" %c", &ch);
            stu[i].option.insert(ch);
        }
    }
    int p[100000] = {0},max = 0, flag = 0;
    for(int i = 0; i < N; i++){
        getchar();
        int k;
        for(int j = 0; j < M; j++){
           // getchar();
            set<char> str;
            if(j != 0)
               scanf(" ");
            scanf("(%d", &k);
            char d;
            for(int r = 0; r < k; r++){
                scanf(" %c", &d);
                str.insert(d);
            }
            scanf(")");
            if(str == stu[j].option)
                p[i] += stu[j].score;
            else
            {
                flag = 1;
                stu[j].p1++; 
            }
            
        }
      //  getchar();
    }
    for(int i = 0; i < N; i++){
        cout << p[i] << endl;
    }
   
    for(int i = 0; i < M; i++){
        if(max < stu[i].p1)
        max = stu[i].p1;
    }
    if(flag == 0)
       cout << "Too simple";
    else
    {cout << max ;
    for(int i = 0; i < M; i++){
        if(stu[i].p1 == max)
           cout << ' ' << stu[i].no;
    }

    }
    
    return 0;
}

방법 2 :

#include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;

struct student
{
   int no; //编号
   int score ;
   int num;
   int right; //正确选项个数
   int p1; //错误次数
   set<char> option;
};

int main()
{
    int N, M;
    cin >> N >> M;
    struct student stu[M];
    for(int i = 0; i < M; i++){
        cin >> stu[i].score >> stu[i].num >> stu[i].right ;
        stu[i].no = i + 1;
        stu[i].p1 = 0;
        for(int  j = 0; j < stu[i].right; j++){
            char ch;
            scanf(" %c", &ch);
            stu[i].option.insert(ch);
        }
    }
    int p[100000] = {0},max = 0, flag = 0;
    for(int i = 0; i < N; i++){
        getchar();
        int k;
        for(int j = 0; j < M; j++){
            //getchar();
            set<char> str;
            if(j != 0)
               scanf(" ");
            scanf("(%d", &k);
            char d;
            for(int r = 0; r < k; r++){
                scanf(" %c", &d);
                str.insert(d);
            }
            if(str == stu[j].option)
                p[i] += stu[j].score;
            else
            {
                flag = 1;
                stu[j].p1++; 
            }
         
        }
        getchar();
    }
    for(int i = 0; i < N; i++){
        cout << p[i] << endl;
    }
  for(int i = 0; i < M; i++){
        if(max < stu[i].p1)
        max = stu[i].p1;
    }
  
    if(flag == 0)
       cout << "Too simple";
    else
    {cout << max ;
    for(int i = 0; i < M; i++){
        if(stu[i].p1 == max)
           cout << ' ' << stu[i].no;
    }

    }
    
    return 0;
}

추천

출처www.cnblogs.com/zhulmz/p/12202084.html