HDU 2946 Letter Cookies
来源:互联网 发布:卡通头像软件app 编辑:程序博客网 时间:2024/05/16 09:10
没优化代码#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
char s[1001];
int m,n,i,j;
int mp1[26],mp2[26];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d",&n);
while(n--)
{
cle(mp1);
scanf("%s",&s);
for(i=0;s[i];i++)
mp1[s[i]-'A']++;
scanf("%d",&m);
while(m--)
{
cle(mp2);
scanf("%s",&s);
for(i=0;s[i];i++)
{
mp2[s[i]-'A']++;
}
for(j=0;j<26;j++)if(mp2[j]>mp1[j])break;
if(j==26)printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
这题没什么算法但还是学习到了很多东西。#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
map<char,int>mp;
map<char,int>mp2;
char s[1010];
int m,mark,n;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d",&n);
while(n--)
{
mp.clear();
cin>>s;
for(int j=0;j<strlen(s);j++)
mp[s[j]]++;
scanf("%d",&m);
char t[110];
for(int i=1;i<=m;i++)
{
cin>>t;
mark=0;
mp2.clear();
for(int k=0;k<strlen(t);k++)
mp2[t[k]]=mp[t[k]];
for(int j=0;j<strlen(t);j++)
{
mp2[t[j]]--;
if(mp2[t[j]]<0){mark=1;break;}
}
if(!mark)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}
- HDU 2946 Letter Cookies
- HDU 4601 Letter Tree
- hdu 4601 Letter Tree
- hdu 4601 Letter Tree
- hdu---1591Encoded Love-letter
- HDU 1591 Encoded Love-letter
- letter
- hdu 4601 Letter Tree 线段树
- HDU 2140 Michael Scofield's letter
- HDU ACM 1591 Encoded Love-letter
- HDU-2140 Michael Scofield's letter 水题
- HDU#2140: Michael Scofield's letter
- cookies
- Cookies
- Cookies
- Cookies
- Cookies
- Cookies
- 01 背包问题
- ios如何集成百度地图---还是自己动手做一下--网上好多博客说的都不甚靠谱。
- CF 275B. Friends and Presents
- CF 275A. Counterexample
- HDU 2955 Robberies
- HDU 2946 Letter Cookies
- HDU 1864最大报销额
- HDU 1231最大连续子序列
- 常见面试之机器学习算法思想简单梳理
- HDU 1003Max Sum
- 用while随机求十个数的和
- HDU 1506Largest Rectangle in a Histogram
- UVA 11991Easy Problem from Rujia Liu?
- solr添加IKAnalyzer分词器