[CF959B]Mahmoud and Ehab and the message题解
超级大模拟
直接用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题解的更多相关文章
- Mahmoud and Ehab and the message
Mahmoud wants to send a message to his friend Ehab. Their language consists of n words numbered from ...
- [CF959E]Mahmoud and Ehab and the xor-MST题解
解法 又是一道结论题? 我的做法比较奇怪且没有证明 #include <cstdio> #include <cmath> #define ll long long int ma ...
- Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...
- [CF959A]Mahmoud and Ehab and the even-odd game题解
题意简述 一个数n,Mahmoud珂以取(即如果取\(k\),使\(n = n - k\))一个正偶数,Ehab珂以取一个正奇数,一个人如果不能取了(对于Mahmoud和Ehab \(n = 0\), ...
- Codeforces 862D. Mahmoud and Ehab and the binary string (二分)
题目链接:Mahmoud and Ehab and the binary string 题意: 一道交互题,首先给出一个字符串的长度l.现在让你进行提问(最多15次),每次提问提出一个字符串,会返回这 ...
- 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 ...
- CF862B Mahmoud and Ehab and the bipartiteness 二分图染色判定
\(\color{#0066ff}{题目描述}\) 给出n个点,n-1条边,求再最多再添加多少边使得二分图的性质成立 \(\color{#0066ff}{输入格式}\) The first line ...
- 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 ...
- 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 语言基础+高级_1-3-Java语言高级_1-常用API_1_第1节 Scanner类_1-API概述和使用步骤
官方翻译的中文版本
- Tensorflow创建和读取17flowers数据集
http://blog.csdn.net/sinat_16823063/article/details/53946549 Tensorflow创建和读取17flowers数据集 标签: tensorf ...
- Zuul网关过滤器中转发头信息不起作用
大家应该都知道在做Zuul网关过滤的时候,如果不在网关过滤时转发头信息,经过网关时头信息就会丢失. 但我用 addZuulRequestHeader转发头信息时,却不起作用,在子服务的controll ...
- from 表单回车自动提交
自动提交的情况 1 表单只有单个输入框 2 type=‘submit 这里注意button默认type为submit 解决方法 1 添加一个隐藏的输入框 2 form添加属性 onsubmit=&q ...
- 使用userAgent区分浏览器版本
使用userAgent区分浏览器版本:https://blog.csdn.net/n447194252/article/details/76255489 JS根据userAgent值来判断浏览器的类型 ...
- 不用找了,300 分钟帮你搞定 Spring Cloud!
最近几年,微服务架构一跃成为 IT 领域炙手可热的话题,大量一线互联网公司因为庞大的业务体量和业务需求,纷纷投入了微服务架构的建设中,像阿里巴巴.百度.美团等大厂,很早就已经开始了微服务的实践和应用. ...
- c++知识点总结3
http://akaedu.github.io/book/ week1 引用:相当于变量的别名.下面r和n就相当于同一回事 ; int &r=n; 引用做函数参数: void swap(int ...
- hash和history
location.hash="aaa" history.pushState({},'', "home") history.replaceState() hist ...
- 【记录】git error:bad signature 解决方法
今天提交git 的时候出现 bad signature 错误,意思是git下的index文件损坏了,需要重新生成下 error: bad signature fatal: index file cor ...
- Python3实现文本预处理
1.数据集准备 测试数据集下载:https://github.com/Asia-Lee/Vulnerability_classify/blob/master/testdata.xls 停用词过滤表下载 ...