fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
Codeforces Round 1062-B (Div. 4) Your Name
최초 업로드: 2025-10-28 22:07:11
최근 수정 시간: 2025-10-28 22:07:11
게시자: rlatjwls3333
카테고리: Codeforces
조회수: 14
# B. Your Name [문제 링크](https://codeforces.com/contest/2167/problem/B) ## Problem Statement khba is writing his girlfriend's name. He has $n$ cubes, each with one lowercase Latin letter written on it. They are arranged in a row, forming a string $s$. His girlfriend's name is also a string $t$, consisting of $n$ lowercase Latin letters. To prove his love, he must check whether it is possible to rearrange the letters of string $s$ so that it becomes her name $t$. ## Input The first line contains an integer $q$ ($1 \le q \le 1000$) — the number of test cases. The first line of each test case contains an integer $n$ ($1 \le n \le 20$). The second line of each test case contains two distinct strings $s$ and $t$, each consisting of $n$ lowercase Latin letters. ## Output For each test case, output "YES" if the letters of $s$ can be arranged to form $t$; otherwise, output "NO". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as positive responses. ## 풀이 두 문자열의 구성요소가 같은지 확인하면 됩니다. 두 문자열을 정렬해서 같은지 확인함으로 구현했습니다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { int n; string a, b; cin >> n >> a >> b; sort(a.begin(), a.end()); sort(b.begin(), b.end()); cout << (a==b ? "YES\n" : "NO\n"); } } ```