Judging Troubles (multiset查找) 分类: ...

本文探讨了在自动评分系统中遇到的问题,通过使用多集和映射来确定两个评分系统的相同提交数量。

Judging Troubles
Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB
Total submit users: 91, Accepted users: 72
Problem 13352 : No special judgement
Problem description

The NWERC organisers have decided that they want to improve the automatic grading of the submissions for the contest, so they now use two systems: DOMjudge and Kattis. Each submission is judged by both systems and the grading results are compared to make sure that the systems agree. However, something went wrong in setting up the connection between the systems, and now the jury only knows all results of both systems, but not which result belongs to which submission! You are therefore asked to help them figure out how many results could have been consistent.

Input

The input consists of:

• one line with one integer n (1 ≤ n ≤ 10^5), the number of submissions;

• n lines, each with a result of the judging by DOMjudge, in arbitrary order;

• n lines, each with a result of the judging by Kattis, in arbitrary order.

Each result is a string of length between 5 and 15 characters (inclusive) consisting of lowercase letters.

Output

Output one line with the maximum number of judging results that could have been the same for both systems.

Sample Input
5
correct
wronganswer
correct
correct
timelimit
wronganswer
correct
timelimit
correct
timelimit

Sample Output
4

Problem Source
NWERC 2014
题意就是看看给出的两个评测系统的n的结果,让你求有多少个是相同的提交。
用multiset,也可以用map做

#include<stdio.h>
#include<string.h>
#include<set>
#include<vector> 
#include<algorithm>
#include<iostream>
#include<string>
#include<stdlib.h> 
#define maxn 100000+100 
using namespace std;
char str[maxn];
char ch[maxn];
string ss;
int main()
{
    int n;
    multiset<string>S;
    scanf("%d",&n);
    getchar();
    for(int i=0;i<n;i++)
    {
       scanf("%s",str);
        S.insert(str);
    }
    //printf("%d\n",S.size());
    int count=0;
    for(int i=0;i<n;i++)
    {
        scanf("%s",ch);
        multiset<string>::iterator it;
        it=S.find(ch);
        if(it!=S.end())
        {
            count++;
            S.erase(it);
        }    
    }
    printf("%d\n",count);
    return 0;
}
//map版本
#include<stdio.h>
#include<string.h>
#include<set>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<stdlib.h>
#include<map>
#define maxn 100000+100
using namespace std;
char str[maxn];
char ch[maxn];
string ss;
int main()
{
    int n;
    map<string,int>S;
    S.clear();
    scanf("%d",&n);
    getchar();
    for(int i=0;i<n;i++)
    {

        scanf("%s",str); 
        S[str]++;
    }
    //printf("%d\n",S.size());
    int count=0;
    for(int i=0;i<n;i++)
    {
        scanf("%s",ch) ;
        if(S[ch]>0)
        {
            count++;
            S[ch]--; 
        }
    }
    printf("%d\n",count);
    return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/NaCl/p/4700582.html

import json import re from openai import OpenAI from colorama import Fore, init # 初始化终端颜色 init(autoreset=True) # 初始化客户端(请替换为你实际使用的 API) client = OpenAI( api_key="sk-c57cd70e76de47d5bd9dcdbe1c49aa74", base_url="https://api.deepseek.com" # 示例地址,请根据实际情况修改 ) # 文件路径 input_file = "C://Users//21991//Desktop//data_source//Chembench//Chembench_reasoning.json" output_file = "C://Users//21991//Desktop//data_source//output.json" # 固定 system prompt:只输出 total,max system_message = { "role": "system", "content": ( "You are a meticulous and serious logic reasoning analyst. " ) } # 读取输入:JSON 数组 with open(input_file, 'r', encoding='utf-8') as f: inputs = json.load(f) # 假设是 [{"input": "..."}, ...] results = [] for idx, item in enumerate(inputs): user_input = ( "Let’s reason through this step by step and counting reasoning steps in detail:\n\n" "- Step 1: understand the question:This question is about...\n" "- Step 2: ...\n" "- Step X: ...\n" "(Note: The step of judging/selecting the answer option should be counted in the total steps, but should NOT be included in the maximum consecutive reasoning steps.)\n\n" "For multiple-choice questions, select the option(s) you believe are correct; there may be more than one correct answer, and it does not have to be only one best option.\n\n" "**Important: Each reasoning step must be atomic and cannot be further subdivided. Do not combine multiple logical operations, facts, or judgments of all options into a single step. **\n\n" "After listing all steps, explicitly analyze the chains of consecutive reasoning steps (without branching):\n" "(For example:\n" "Chain 1: Steps 1–4 (4 steps)\n" "Chain 2: Steps 5–6 (2 steps)\n" "Chain 3: Steps 7–9 (3 steps)\n" "Chain 4: Step 10 (1 step)\n" "Max consecutive = 4.\n" "Maximum consecutive reasoning steps without branching: 4 (excluding the answer selection step)).\n\n" "Then output strictly in the following format:\n" "<total>X</total>,<max>Y</max>\n\n" "Now, for the following question, follow the above format exactly:\n" "Question: " + item.get("input", "").strip() ) if not user_input: print(Fore.YELLOW + f"跳过第 {idx+1} 条空输入") results.append({ "input": "", "output": "", "total": 0, "max": 0 }) continue print(Fore.YELLOW + f"\n\n[第 {idx+1}/{len(inputs)}] 正在处理:\n{user_input}") # 构建消息历史:每次都独立处理(无上下文) messages = [ system_message, {"role": "user", "content": user_input} ] try: # 调用模型(关闭流式更简单,因为我们只需要一行数字) response = client.chat.completions.create( model="deepseek-chat", # 或其他支持推理的模型 messages=messages, stream=False, temperature=0.1 # 更确定性输出 ) # 提取模型回复 raw_output = response.choices[0].message.content.strip() print(Fore.CYAN + f"模型输出: {raw_output}") # 解析 total, max try: # 先尝试直接匹配 <total>X</total>,<max>Y</max> match = re.search( r'<total>\s*(\d+)\s*</total>\s*,\s*<max>\s*(\d+)\s*</max>', raw_output ) if match: total = int(match.group(1)) max_consecutive = int(match.group(2)) else: # 再尝试匹配 X,Y 格式(可能在结尾) match2 = re.search(r'(\d+)\s*,\s*(\d+)\s*$', raw_output) if match2: total = int(match2.group(1)) max_consecutive = int(match2.group(2)) else: raise ValueError(f"输出格式不符: {raw_output}") except Exception as e: print(Fore.RED + f"解析失败,使用默认值 0,0 (错误: {e})") total = 0 max_consecutive = 0 # 构造结果 result_entry = { "input": user_input, "output": raw_output, "total": total, "max": max_consecutive } results.append(result_entry) print(Fore.GREEN + f"→ 解析为: total={total}, max={max_consecutive}") print('-' * 60) except Exception as e: print(Fore.RED + f"请求失败: {e}") results.append({ "input": user_input, "output": "", "total": 0, "max": 0 }) # 写回完整的 JSON 数组(只保留 total>=9 且 max>=4 的结果) filtered_results = [ r for r in results if r["total"] >= 9 and r["max"] >= 4 ] with open(output_file, 'w', encoding='utf-8') as f: json.dump(filtered_results, f, ensure_ascii=False, indent=2) print(Fore.GREEN + f"\n✅ 所有 {len(filtered_results)} 条数据已处理完毕,结果已保存至 '{output_file}'") 修改,使得输出格式回答不符是再次输入相同的问题
最新发布
09-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值