超级大模拟

直接用map吧string对应到编号上来,然后在开个数组把每个编号对应到每个可以互相转化区块上来,预处理出区块的最小值,使用时直接取最小是即可

代码

#include <cstdio>
#include <iostream>
#include <map>
#define ll long long
#define min(a,b) ((a<b)?a:b) using namespace std; inline ll read(){
ll x = 0; int zf = 1; char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') zf = -1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
} map<string, int> mp;
string s[100005];
int a[100005];
int dy[100005];
int val[100005]; int main(){
int n = read(), k = read(), m = read();
for (int i = 1; i <= n; ++i)
cin >> s[i];
for (int i = 1; i <= n; ++i)
a[i] = read(), mp[s[i]] = i;
int q;
for (int i = 1; i <= k; ++i)
val[i] = 2147483647;
for (int i = 1; i <= k; ++i){
q = read();
for (int j = 0; j < q; ++j){
int t = read();
dy[t] = i, val[i] = min(val[i], a[t]);
}
}
string c; ll ans = 0;
for (int i = 1; i <= m; ++i){
cin >> c;
ans += val[dy[mp[c]]];
}
printf("%lld", ans);
return 0;
}

[CF959B]Mahmoud and Ehab and the message题解的更多相关文章

  1. Mahmoud and Ehab and the message

    Mahmoud wants to send a message to his friend Ehab. Their language consists of n words numbered from ...

  2. [CF959E]Mahmoud and Ehab and the xor-MST题解

    解法 又是一道结论题? 我的做法比较奇怪且没有证明 #include <cstdio> #include <cmath> #define ll long long int ma ...

  3. Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)

    Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...

  4. [CF959A]Mahmoud and Ehab and the even-odd game题解

    题意简述 一个数n,Mahmoud珂以取(即如果取\(k\),使\(n = n - k\))一个正偶数,Ehab珂以取一个正奇数,一个人如果不能取了(对于Mahmoud和Ehab \(n = 0\), ...

  5. Codeforces 862D. Mahmoud and Ehab and the binary string (二分)

    题目链接:Mahmoud and Ehab and the binary string 题意: 一道交互题,首先给出一个字符串的长度l.现在让你进行提问(最多15次),每次提问提出一个字符串,会返回这 ...

  6. CF 862A Mahmoud and Ehab and the MEX【数组操作】

    A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 megabytes in ...

  7. CF862B Mahmoud and Ehab and the bipartiteness 二分图染色判定

    \(\color{#0066ff}{题目描述}\) 给出n个点,n-1条边,求再最多再添加多少边使得二分图的性质成立 \(\color{#0066ff}{输入格式}\) The first line ...

  8. Codeforces 862A Mahmoud and Ehab and the MEX

    传送门:CF-862A A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 ...

  9. E - Mahmoud and Ehab and the bipartiteness CodeForces - 862B (dfs黑白染色)

    Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipa ...

随机推荐

  1. 关于崩溃报告的日志以及dump文件

    在用户使用软件的过程当中突然产生软件崩溃的问题,必须采取相关的措施去拦截崩溃产生的原因,这有助于程序员解决此类崩溃的再次发生.特别是有些难以复现的崩溃,不稳定的崩溃,更有必要去调查崩溃产生的原因.一般 ...

  2. Java各类型占字节数

    byte 1字节short 2字节int 4字节long 8字节float 4字节double 8字节char 2字节boolean 1字节 其中,换算关系: 1GB=1024MB 1MB=1024K ...

  3. 桌面应用开发用到的Framework

    桌面应用开发用到的Framework https://github.com/zhangqs008/Framework_Winform

  4. MVC 源码系列之控制器激活(一)

    Controller的激活 上篇说到Route的使用,GetRoute的方法里面获得RouteData.然后通过一些判断,将最后的RouteData中的RouteHandler添加到context.R ...

  5. C#扩展方法 DataTable.ToEntitys

    类A需要添加功能,我们想到的就是在类A中添加公共方法,这个显而易见肯定可以,但是由于某种原因,你不能修改类A本身的代码,但是确实又需要增加功能到类A中去,怎么办? 这个时候扩展方法(Extension ...

  6. Java ——循环

    本节重点思维导图  while循环 while(true) { System.out.println("1");//不断循环打印“1” } int i = 1; while(i & ...

  7. PHPstorm Xdebugger最全详细

    0 Xdebug调试的原理(选看) 图0-1 单机调试原理示意图 图0-2 多机调试原理示意图 对于PHP开发,初来咋到,开发环境的搭建和理解感觉是最烦人的一件事了.不像JAVA,打开一个Eclips ...

  8. vue集成汉字转拼音或提取首字母

    需求:             有时我们为了节省用户的维护量,需要根据中文生成出相应的拼音和缩写 解决:            此方法是利用汉字和Unicode编码对应找到相应字母 一.编写汉字和编码 ...

  9. 001--PowerDesigner连接MySQL

    PowerDesigner连接MySQL(一) 博客地址:https://blog.csdn.net/codemonkey_king/article/details/53263597 https:// ...

  10. thead tbody tfoot

    <!DOCTYPE html> <html lang="en"> <head> <title>Title</title> ...