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 ...
随机推荐
- [LeetCode系列] 最长回文子串问题
给定字符串S, 找到其子串中最长的回文字符串. 反转法: 反转S为S', 找到其中的最长公共子串s, 并确认子串s在S中的下标iS与在S'中的下标iS'是否满足式: length(S) = iS ...
- bzoj1037生日聚会
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1037 任意区间的话,可以从所有后缀区间考虑. 因为每一个区间一定是某一时刻的一个后缀区间,所 ...
- linux中bin与sbin目录的作用及区别介绍
linux中bin与sbin目录的作用及区别介绍 本文介绍下,linux中的二个主要目录:bin与sbin,它们的作用与区别,学习linux的朋友可以参考下 在linux系统中,有两个重要的目录:bi ...
- 【python】Python框架、库和软件资源大全
很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世界各地的程序员们都能够贡献他们的代码与创新. Python就是这样一门受到全世界各地开源社区支持的语言. ...
- mysql负载均衡完美解决方案
http://blog.csdn.net/v1v1wang/article/details/8771974 1.环境: mysql 5ubuntu10.04 x86_64 mdb1 et ...
- Python 字串处理
#!/usr/bin/python #-*- coding:utf-8 –*- import os import sys import re import shutil import xlrd imp ...
- 添加APP右上角数字提醒标识
mui.plusReady(function() { plus.nativeUI.closeWaiting(); mui.currentWebview.show(); //1.设置app右上角数字提醒 ...
- LAMP的安装和注意事项
LAMP--Linux+Apache(httpd)+MySQL+PHP,是常用的web服务器架构,下面接受编译安装的过程,以及出现的错误. 注意事项: 1. 扩展epel源:参照:http://www ...
- UI“三重天”之Selenium(一)
关注一下UI自动化,记一记笔记. UI自动化的优缺点: 关于UI自动化的优缺点想来大家都有了解,优点:解放人力(并不是完全解放),用机器(涵盖工具.脚本等)代替人工完成测试工作,将测试用例转化为脚本实 ...
- 根据插件Swipe,结合jQuery封装成的新的jQuery插件
swipe支持电脑上的自动滑动,也支持手机端的滑动效果.但是每次调用只能支持一个效果或者说一个页面出现n个这样的效果,我们就得调用n次这个插件. 我使用swipe+jQuery使得swip变得方便使用 ...