CodeForces 518B Tanya and Postcard (题意,水题)
题意:给定两个字符串,然后从第二个中找和第一个相同的,如果大小写相同,那么就是YAY,如果大小写不同,那就是WHOOPS。YAY要尽量多,其次WHOOPS也要尽量多。
析:这个题并不难,难在读题懂题意。首先把两个字符串的的每个字符存起来,然后,先扫一遍,把所有的能YAY的都选出来,剩下的再尽量先WHOOPS。
代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <cmath>
#include <map>
#include <cctype> using namespace std;
const int maxn = 1000 + 5;
map<char, int> mp1;
map<char, int> mp2;
string s1, s2; int main(){
cin >> s1 >> s2;
for(int i = 0; i < s1.size(); ++i)
++mp1[s1[i]];
for(int i = 0; i < s2.size(); ++i)
++mp2[s2[i]]; int cnt1 = 0, cnt2 = 0;
for(int i = 0; i < 26; ++i){
if(mp1[i+'a'] >= mp2[i+'a']){
cnt1 += mp2[i+'a'];
mp1[i+'a'] -= mp2[i+'a'];
mp2[i+'a'] = 0;
}else{
cnt1 += mp1[i+'a'];
mp2[i+'a'] -= mp1[i+'a'];
mp1[i+'a'] = 0;
}
if(mp1[i+'A'] >= mp2[i+'A']){
cnt1 += mp2[i+'A'];
mp1[i+'A'] -= mp2[i+'A'];
mp2[i+'A'] = 0;
}else{
cnt1 += mp1[i+'A'];
mp2[i+'A'] -= mp1[i+'A'];
mp1[i+'A'] = 0;
}
}
for(int i = 0; i < 26; ++i){
if(mp1[i+'a']) cnt2 += min(mp1[i+'a'], mp2[i+'A']);
if(mp1[i+'A']) cnt2 += min(mp1[i+'A'], mp2[i+'a']);
}
printf("%d %d\n", cnt1, cnt2);
return 0;
}
CodeForces 518B Tanya and Postcard (题意,水题)的更多相关文章
- CodeForces 518B. Tanya and Postcard
B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- codeforces 518B. Tanya and Postcard 解题报告
题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...
- CodeForces 682B Alyona and Mex (题意水题)
题意:给定一个序列,你可以对这里面的数用小于它的数来代替,最后让你求,改完后的最大的序列中缺少的最小的数. 析:这个题,读了两个多小时也没读懂,要是读懂了,肯定能做出来...没什么可说的,就是尽量凑1 ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
随机推荐
- const_cast
函数原型: const_cast < type-id > ( expression ) 去掉const属性:const_cast<int*> (&num),常用,因为不 ...
- hibernate enum映射详解
hibernate enum映射详解 在这里介绍注解的形式,如果想要了解XML配置的方式,可以自行查找相关资料. 例如以下Entity @Entity @Table(name = "t_us ...
- centos6.6 myphpadmin
基本环境为:Centos6.6+Apache2.2.15+php5.3.3+Mysql5.1.73 开始下载了网站上最新版本myPhpAdmin4.3.8安装后打开浏览器为空白页,后百度后都讲是与PH ...
- 设置vim颜色方案
获取所有vim颜色配置方案 ls /usr/share/vim/vim74/colors/ [root@lx ~]# ls /usr/share/vim/vim74/colors/ blue.vim ...
- xargs命令学习
1.xargs复制文件 目录下文件结构为: . ├── demo1 │ ├── test.lua │ ├── test.php │ └── test.txt └── demo2 执行命令: find ...
- [持续更新]一些zyys的题的集合
Luogu P1119 灾后重建 Sol:对于每个中转点K,需且仅需以此松弛一次 Key words:Floyd,本质活用 考题 路径数 题目描述: Euphemia到一个N*N的药草田里采药,她从左 ...
- bzoj4591 [Shoi2015]超能粒子炮·改
Description 曾经发明了脑洞治疗仪&超能粒子炮的发明家SHTSC又公开了他的新发明:超能粒子炮·改--一种可以发射威力更加 强大的粒子流的神秘装置.超能粒子炮·改相比超能粒子炮,在威 ...
- 【洛谷】P1247 取火柴游戏(Nim)
题目 传送门:QWQ 分析 蒟蒻根本不会博弈论..... 只知道异或和判断Nim游戏.. 不是很懂输出的选择,所以发一篇博客以待复习 代码 #include <bits/stdc++.h> ...
- Bootstrap的介绍和响应式媒体查询
Bootstrap的介绍 凡是使用过Bootstrap的开发者,都不在乎做这么两件事情:复制and粘贴.哈哈~,是的使用Bootstrap非常简单,但是在复制粘贴之前,需要先对Bootstrap的用法 ...
- T-SQL 总结
SP0_AddLinkedServer.sql [创建Linked SQL Server ] USE [master] GO ) drop procedure dbo.SP_Temp_AddLinke ...