-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
60-xxubin04 #227
60-xxubin04 #227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setμ μ¬μ©νλ©΄ μ½κ² ꡬν μ μλ μ¬νν λ¬Έμ μ£ ~
μμ μ C++λ‘ νμμλλ°, set 2κ°λ₯Ό μ¬μ©νκ³ κ΅μ§ν©μΌλ‘ κ±°λ₯΄λ λ°©μ보λ€λ never_listenμ setμ λ£μ λ€ never_listenμ΄ λ μ΄λ¦λ€μ νλμ© μ
λ ₯λ°μΌλ©° never_listenμ "μλ€λ©΄" listμ λ£λ μμΌλ‘ κ²μ¬ν΄ νν°λ§ λ μΉκ΅¬λ€λ§ μ λ ¬ν΄μ μΆλ ₯νλ κ² λ λΉ¨λΌμ κ·Έλ κ² νμλ κΈ°μ΅μ΄ μλ€μ.
#include <iostream>
#include <unordered_set>
#include <algorithm>
using namespace std;
int main()
{
cin.tie(nullptr)->sync_with_stdio(false);
int N, M; cin >> N >> M;
unordered_set<string> NeverSeen;
string Name;
while(N--)
{
cin >> Name;
NeverSeen.emplace(Name);
}
vector<string> OffBrand;
while(M--)
{
cin >> Name;
if(NeverSeen.count(Name))
{
OffBrand.emplace_back(Name);
}
}
sort(OffBrand.begin(), OffBrand.end());
cout << OffBrand.size() << "\n";
for(const string& Ans : OffBrand)
{
cout << Ans << "\n";
}
return 0;
}
for m in range(M): | ||
never_seen.add(input().rstrip()) | ||
|
||
never_listen_seen = sorted(list(never_listen & never_seen)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ€μ€μΉγ
..!
setμ μ΄λ κ² μ¬μ©νλ©΄ κ΅μ§ν©μ΄ λλκ΅°μ?
μ¬λ°κ³ μλ½νκ±° μμκ°λλ€!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ dictμΌλ‘ ν΄μ μ΄λ¦ νμ cnt ν΄μ€¬μ΅λλΉ!
from collections import defaultdict
input = open("input.txt").readline
listen, watch = map(int,input().split())
answer = []
cnt = defaultdict(int)
for i in range(listen+watch):
cnt[input().rstrip()] += 1
for k, v in cnt.items():
if v == 2:
answer.append(k)
print(len(answer))
for a in sorted(answer):
print(a)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ§ λ£μ§λ 보μ§λ λͺ»ν λ¬Έμ λ‘κ΅°μ!
νμ΄μ¬μμλ & μ°μ° μ΄νλ‘λ setμ΄ λ°νλλ§,
sorted λ©μλ μ΄νλ‘ list κ° λ°νλμ μλμ κ°μ΄ μμ±μ΄ κ°λ₯ν©λλ€ !
n, m = map(int, input().split())
no_see = set()
for _ in range(n):
no_see.add(input())
no_hear = set()
for _ in range(m):
no_hear.add(input())
no_see_hear = no_see & no_hear
print(len(no_see_hear))
for i in sorted(no_see_hear):
print(i)
π λ¬Έμ λ§ν¬
λ°±μ€ 1764: λ£λ³΄μ‘
βοΈ μμλ μκ°
10λΆ
β¨ μλ μ½λ
1. λ¬Έμ μ΄ν΄
Nλ§νΌμ λ€μ΄λ³΄μ§ λͺ»ν μ¬λ μ΄λ¦μ μ λ ₯λ°λλ€.
Mλ§νΌμ 보λ λͺ»ν μ¬λ μ΄λ¦μ μ λ ₯λ°λλ€.
μ΄λ, setμ μ΄λ¦λ€μ μ μ₯ν¨μΌλ‘μ¨ λμ€μ λ£λ 보λ λͺ»ν μ¬λμ μ΄λ¦μ μΆλ ₯νλλ° μ©μ΄νλ€.
2. μ 체 μ½λ
π μλ‘κ² μκ²λ λ΄μ©
λ무 μ¬μ΄ λ¬Έμ λ₯Ό νμλ€μ..νν..
λ€μμ μ’ λ μ΄λ €μ΄ λ¬Έμ λ₯Ό νκ² μ΅λλ€..!