codeforces 518B Tanya and Postcard
来源:互联网 发布:dreamweaver淘宝首页 编辑:程序博客网 时间:2024/05/27 09:45
题目链接:点击打开链接
题目大意是给一个模板串a,以及另一个长度大于模板串的串b,两个字符集均为大小写英文字母。从b中选出字符构造串c使得c尽量与模板串a相同,优先让a和c相同位置上的字符字母和大小写均相同,如果无法大小写相同,尽量让字母相同。输出c和a中二者都相同和只有字母相同的数量。
此处需要注意,为了满足优先级,必须先对高优先级处理,全部处理完以后再对低优先级处理...(就wa在这里...有点2)
#include <bits/stdc++.h>using namespace std;#define N 1000000char s[N],t[N];int k[300],m[300];int main(){ memset(k,0,sizeof(k)); gets(s); gets(t); int n,mm,tmp; n = strlen(t); for(int i = 0; i < n;i++){ k[t[i]]++; } n = strlen(s); for(int i = 0; i < n;i++){ m[s[i]]++; } int ans = 0,ans1 = 0; for(int i = 55; i < 130;i++){ if(m[i]>0&&k[i]>0){ tmp = min(k[i],m[i]); k[i]-=tmp; m[i]-=tmp; ans+=tmp; } } for(int i = 55;i < 130;i++){ if(m[i] > 0 && k[i] == 0){ if(i > 'Z' && k[ i - 32] > 0) { tmp = min(k[i-32],m[i]); k[i-32]-=tmp; m[i]-=tmp; ans1+=tmp; } else{ if(i<'a' && k[i + 32]>0){ tmp = min(k[i + 32],m[i]); k[i+32] -= tmp; m[i] -= tmp; ans1+=tmp; } } } } printf("%d %d\n",ans,ans1); return 0;}
0 0
- codeforces 518B Tanya and Postcard
- codeforces 518B Tanya and Postcard
- CodeForces 518B Tanya and Postcard
- CodeForces 518B Tanya and Postcard 计数
- CodeForces - 518B Tanya and Postcard(水题)
- B. Tanya and Postcard
- Codeforces Round #293 (Div. 2) -- B. Tanya and Postcard
- Codeforces Round #293 (Div. 2) B. Tanya and Postcard
- CF 518B(Tanya and Postcard-计数统计)
- 518B - Tanya and Postcard【哎还是string】
- Codeforces Round #324 B Kolya and Tanya
- codeforces 584B Kolya and Tanya
- B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2)B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya
- *LeetCode-Reverse Integer
- sdio 初始化流程
- java连接各种数据库配置
- 例题10-15 杆子的排列 UVa1638
- 默染江山——oc内存管理
- codeforces 518B Tanya and Postcard
- 35 岁前程序员要规划好的四件事
- 算法导论(三版):第一章第二节课后题 以及 第一章思考题
- Spring MVC @PathVariable with dot (.) is getting truncated.
- 云存储的核心是大数据模式---服务化--初创公司仅能提供更多技术解决方案非基础运营
- vim学习笔记
- Freemarker静态化时渲染自定义标签
- 《第一行代码-Android》学习笔记(二十四)
- property和constructor-arg的使用