zoukankan      html  css  js  c++  java
  • So Many Skirt

    xiaoA is a beautiful girl, and she has so many skirts that she won't wear a skirt a second time before the skirt is washed. Now xiaoA wants to go shopping, how many skirts she can choose to wear?

    In order to distinguish these skirts, she gives out every skirt with a unique name.

    Input

    The first line of input contains a positive integer T (T <= 100), the number of test cases.

    Each test case contains two integers N and M (1<=N, M<=100) in the first line.

    N is the number of skirts.M is the number of operations.

    Then N lines follow. Every line contains a word and the word is not longer than 10.

    Then M lines follow. Each line contains a character 'D' or 'W' and the name of a skirt.

    'D' indicates that xiaoA has wore the skirt. 'W' indicates that xiaoA has washed the skirt.

    Output

    After the M operations, you need to output that how many skirts can be chosen by xiaoA to wear.

    Sample Input

    1

    5 5

    SkirtA

    SkirtB

    SkirtC

    SkirtD

    SkirtE

    D SkirtA

    D SkirtB

    D SkirtC

    D SkirtD

    W SkirtA

    Sample Output

    2

    #include <iostream>
    #include <string>
    #include <map>
    using namespace std;
    
    
    
    void main()
    {
    	map<string,int> skirts;
    	map<string,int>::iterator it;
    	int T;
    	cin >> T;
    	for (int i = 0;i<T;i++)
    	{
    		int N,M;
    		cin >> N>>M;
    		skirts.clear();
    		string skirtName;
    		for (int j = 0;j<N;j++)
    		{
    			cin >> skirtName;
    			skirts[skirtName] = 1; //表示都洗过了,都能穿
    		}
    		for (int j = 0;j<M;j++)
    		{
    			string Operator;
    			cin >> Operator >> skirtName;
    			if (Operator == "D")
    			{
    				skirts[skirtName] = 0;
    			}else if (Operator == "W")
    			{
    				skirts[skirtName] = 1;
    			}
    		}
    
    		//最后输出能穿的衣服的个数
    
    		int count = 0;
    		for (it = skirts.begin();it!=skirts.end();it++)
    		{
    			count += it->second;
    		}
    		cout << count << endl;
    	}
    }
  • 相关阅读:
    C# 连接 Socks5 代理
    使用EF Core 连接远程oracle 不需要安装oracle客户端方法
    PLSQL Developer 12 汉化包下载
    对象异步赋值bug记录
    图片缩放
    根据对象的属性去重,获取新数组
    小程序购物车抛物线(贝塞尔曲线实现)
    文字溢出,换行方法整理
    整理一些最近开发小程序的经验
    【莫傷曉_开发笔记】linux java绘图字体乱码问题
  • 原文地址:https://www.cnblogs.com/speedmancs/p/1715616.html
Copyright © 2011-2022 走看看