백준 7785 c++

magicdrill·2024년 3월 20일

백준 문제풀이

목록 보기
180/673

백준 7785 c++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;

int input(int lower, int upper);
void input_inout_infomation(map <string, bool> &info_list, int size);
void print_result(map <string, bool> info_list, int size);

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	map <string, bool> m;
	
	n = input(2, 1000000);
	input_inout_infomation(m, n);
	print_result(m, n);


	return 0;
}

int input(int lower, int upper)
{
	int A;

	while (1)
	{
		cin >> A;
		if (A >= lower && A <= upper)
		{
			break;
		}
		else
		{
			;
		}
	}

	return A;
}

void input_inout_infomation(map <string, bool> &info_list, int size)
{
	int i;
	string name, inout;

	for (i = 0; i < size; i++)
	{
		cin >> name >> inout;
		if (inout == "enter")
		{
			info_list[name] = true;
		}
		else
		{
			info_list[name] = false;
		}
	}

	return;
}

void print_result(map <string, bool> info_list, int size)
{
	for (auto i = info_list.rbegin(); i != info_list.rend(); i++)
	{
		if (i->second)
		{
			cout << i->first << "\n";

		}
		else
		{
			;
		}
	}

	return;
}

0개의 댓글