题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805270356541440

这道题主要是把输入格式给搞定,思路是一个数组记录分数,一个数组记录正确答案,一个数组记录错误数量
中间输入的时候新建一个集合用来判断,大概用到的就是这些
另一个小技巧就是temp值可以反复赋值,如果之后用不到的话

代码

  1. #include<cstdio>
  2. #include<vector>
  3. #include<set>
  4. using namespace std;
  5. int main(){
  6. int n, m, temp, k;
  7. scanf("%d%d", &n, &m);
  8. vector<set<char>> right(m);
  9. vector<int> total(m), wrongCnt(m);
  10. for(int i = 0; i < m; i++){
  11. scanf("%d%d%d", &total[i], &temp, &k);
  12. for(int j = 0; j < k; j++){
  13. char c;
  14. scanf(" %c", &c);
  15. right[i].insert(c);
  16. }
  17. }
  18. for(int i = 0; i < n; i++){
  19. int score = 0;
  20. scanf("\n");
  21. for(int j = 0; j < m; j++){
  22. if(j != 0) scanf(" ");
  23. scanf("(%d", &k);
  24. set<char> st;
  25. char c;
  26. for(int l = 0; l < k; l++){
  27. scanf(" %c", &c);
  28. st.insert(c);
  29. }
  30. scanf(")");
  31. if(st == right[j]){
  32. score += total[j];
  33. } else {
  34. wrongCnt[j]++;
  35. }
  36. }
  37. printf("%d\n", score);
  38. }
  39. int maxCount = 0;
  40. for(int i = 0; i < m; i++){
  41. if(wrongCnt[i] > maxCount) maxCount = wrongCnt[i];
  42. }
  43. if(maxCount == 0) printf("Too simple");
  44. else{
  45. printf("%d", maxCount);
  46. for(int i = 0; i < m; i++){
  47. if(wrongCnt[i] == maxCount)printf(" %d", i + 1);
  48. }
  49. }
  50. return 0;
  51. }