[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 ...
随机推荐
- free pascal 修改字符集,会导致 dos 不能显示 汉字。 处理方法如下
http://www.cnblogs.com/yjken/p/3917932.html 让windows系统的DOS窗口也可以显示utf8字符集 C:\Users\Administrator> ...
- beego 注解路由无效问题分析
问题描述:学习 beego 框架发现注解路由无效,除了不能找到路由外,未见任何异常. 问题解决:将配置文件中的 runmode 更改为 dev 模式. 问题分析: 如果没有设置过 runmode 不会 ...
- Windows操作系统命令整理-Win7
注册表(Windows95以后Windows系统版本,windows server中regedit和regedit32合并为一个新的编辑器,名称仍然是regedit) HKEY_LOCAL_MACHI ...
- js 相关好文章推荐
1.关于xmlhttprequest https://segmentfault.com/a/1190000004322487 2.XMLHttpRequest2 新技巧 https://www.htm ...
- Mac--PHP已经开启gd扩展验证码不显示
错误显示:Call to undefined function imagettftext() 原因: mac系统中自带的php的gd库中,缺少对freetype的支持,导致图片无法显示. 解决: 1 ...
- Flutter修改状态栏颜色以及字体颜色
Flutter沉浸式状态栏 void main() { runApp(MyApp()); if (Platform.isAndroid) { // 以下两行 设置android状态栏为透明的沉浸.写在 ...
- [19/05/16-星期四] HTML_body标签(表格标签)
一.概念 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...
- quartz任务调度的详解
1.Quartz包含3个核心(调度器.作业类.触发器) (1).作业类:只需要实现org.quartz.job接口,同时包含里面的一个方法体execute()[这是被调度的作业体] (2).调度器:是 ...
- hdu-4185.loiol_skimming(简单二分匹配模型)
/************************************************************************* > File Name: hdu-4185. ...
- [面試題]C符號的優先順序
int x = 0; if (x = 0 || x == 0) printf("%dn", x); printf("%dn", x); 參考C的優先表, 其實就 ...