알고리즘/백준

백준 11346 Cornell Party - Retry

등반 2021. 12. 27. 01:19

https://www.acmicpc.net/problem/11346

 

11346번: Cornell Party - Retry

Ezra Cornell and A. D. White learned their lesson from their last party, so this time they decided to use names instead of identifiers. They also realized that they shouldn’t trust their memories so much, so they’ve decided to write down the guest name

www.acmicpc.net

문제 해설

코넬에서 파티를 하는데, 두 명이 각각 참가자들의 명부를 기록한다.

동명이인은 없다.

몇 명이 있는지 출력하라.

 

두 명이 각각 명부를 기록했다곤 하지만,

어차피 중복을 없애야 하고, 기록은 통합해야 하므로

set하나만 만들어 모두 집어넣으면 된다.

#include <iostream>
#define fio cin.tie(0)->sync_with_stdio(0)
using namespace std;

#include <set>
int main(){
    fio;
    int T; cin >> T;
    for(int t = 1; t <= T; t++){
        int N, M; cin >> N >> M;
        set<string> set_;
        for(int i=0; i<N; i++){
            string tmp; cin >> tmp;
            set_.insert(tmp);
        }
        for(int i =0; i <M; i++){
            string tmp; cin >> tmp;
            set_.insert(tmp);
        }
        cout << set_.size() <<'\n';
    }
    
    return 0;
}

'알고리즘 > 백준' 카테고리의 다른 글

백준 11645 I’ve Been Everywhere, Man  (0) 2021.12.27
백준 11507 카드셋트  (0) 2021.12.27
백준 11235 Polling  (0) 2021.12.27
백준 11116 교통량  (0) 2021.12.27
백준 10689 Hamza  (0) 2021.12.27