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;
    	}
    }
  • 相关阅读:
    sql语句技巧
    逻辑查询处理的步骤
    left join 和 left outer join的区别
    SQL 笛卡尔积
    SQL 分类
    显示数据库中的表
    数据库备份 恢复
    增删主键及修改表名
    Securing Data笔记
    System Monitoring之"文件系统"
  • 原文地址:https://www.cnblogs.com/speedmancs/p/1715616.html
Copyright © 2011-2022 走看看