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 ...
随机推荐
- Mac下忘记mysql密码怎么办
Mac本地安装了数据库,忘记数据库密码的情况下,可以按照以下步骤进行修改密码 step1: 关闭mysql服务: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服 ...
- FastAdmin 是如何利用 Git 管理插件代码的?
FastAdmin 是如何利用 Git 管理插件代码的? 由于 FastAdmin 的插件很多,如果每一个插件用一个项目来管理,可以倒是可以,但是项目还多了. 但是如果使用文件夹在同一级的的方式又不方 ...
- centos6.5下tomcat安装
1.安装JDK 安装:rpm –ivh jdk-7u5-linux-i586.rpm2.配置Tomcat 解压:tar -zxvf apache-tomcat-8.0.11.tar.gz 移动到/us ...
- redhat 防火墙禁止允许的IP链接指定的端口
编辑:iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 192.168.4.3 --dport 80 -j A ...
- 在laravel之外使用eloquent
视频地址 https://laracasts.com/lessons/how-to-use-eloquent-outside-of-laravel
- phpcms 实现动态价格
什么是动态价格(自命名)?—— 一般来说商品有个固定的价格,随着节假日或者促销活动可能会发生价格变化,结束后又恢复原价,如果每次价格变化都需要修改价格,那么不仅在时间上不好把握,也需要消耗更多的人力 ...
- 使用pandas时遇到ValueError: numpy.dtype has the wrong size, try recompiling
[问题]使用pandas时遇到ValueError: numpy.dtype has the wrong size, try recompiling [原因] 这是因为 Python 包的版本问题,例 ...
- Supervisor安装与配置
Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统 ...
- leetcode38
public class Solution { public string CountAndSay(int n) { //1 //11 //21 //1211 //111221 //312211 // ...
- PS7.0快捷键和使用技巧
选择工具:矩形.椭圆选框工具 [M]裁剪工具 [C]移动工具 [V]套索.多边形套索.磁性套索 [L]魔棒工具 [W] 编辑工具:修复画笔.修补工具 [J]画笔.铅笔工具 [B]橡皮图章.图案图章 [ ...