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 ...
随机推荐
- 【转】Ubuntu13.04配置:Vim+Syntastic+Vundle+YouCompleteMe
原文网址:http://www.cnblogs.com/csuftzzk/p/3435710.html 序言 使用Ubuntu和vim已经有一段时间了,对于Vim下的插件应用,我总是抱着一股狂热的态度 ...
- Docker中配置国内镜像
1. 为什么要为docker配置国内镜像 在正常情况下,docker有一个默认连接的国外官方镜像,在国外的网友访问该官方镜像自然不成问题,但是国内毕竟不是国外,由于国情不同,中国的网络访问国外官方 ...
- MYSQL中写SQL语句,取到表中按ID降序排列(最新纪录排在第一行)
'select * from bugdata where id>0 order by id desc'
- am335x内核初始化路径
/arch/arm/mach-omap2/board_am335xevm.c中 1.myd_am335x_dev_cfg[]{ evm_nand_init() ... myir_gpio_init() ...
- Phonegap中插件管理
一.cordova-plugin-console控制台插件的使用 1.进入工程路径后,输入如下命令: cordova plugin add cordova-plugin-console 2. 查看插件 ...
- Windows Redis安装,Java操作Redis
一.Redis 的安装 1.Redis 下载 Windows 版本下载:https://github.com/dmajkic/redis/downloads 2.解压到 C:\redis-2.4.5- ...
- column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd.
1558 1547 column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd. ...
- excel 条件格式 心的
例1: 图1 图2 $G$16 ≠G16 用G16就可以用格式刷拖动,$G$16用格式刷刷到其它单元格保持不变,判断单元格函数 ISBLANK(G16)=TRUE
- css用法大全
direction:控制文本方向 ltr:默认.文本方向从左到右. rtl:文本方向从右到左. inherit:规定应该从父元素继承 direction 属性的值. <select name=& ...
- oracle 11g RAC 的一些基本概念(四)
RAC 在Grid Infrastructure安装完以后,我们把注意力转移到集群上的Oracle软件的安装上来.我们看到,Grid Infrasctructure提供了运行RAC的框架,包括集群 ...