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;
    	}
    }
  • 相关阅读:
    js
    第三方jar包导入unity
    xcode打包苹果应用遇到的问题及解决方法
    ios打包unity应用以及配置签名
    unity打包安卓应用及生成签名
    Unity实现用户条款弹窗及登录
    Unity协程实现伪加载页面
    Unity配置安卓开发环境
    Unity中用Mono插件解析xml文件
    Excel关联xml文件
  • 原文地址:https://www.cnblogs.com/speedmancs/p/1715616.html
Copyright © 2011-2022 走看看