[ 문제 ]
[ 접근방법 ]
입력마다 소문자 개수를 체크하여 비교한다.
[ 소스코드 ]
#include <iostream>
using namespace std;
int n;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
while(n--){
string a, b;
int x[26] = {};
cin >> a >> b;
for(auto ch : a)x[ch - 'a']++;
for(auto ch : b)x[ch - 'a']--;
bool chk = true;
for(int i : x){
if(i != 0){
chk = false;
break;
}
}
cout << (chk ? "Possible\n" : "Impossible\n");
}
return 0;
}
'PS' 카테고리의 다른 글
[ 백준 / C++ ] 3085 : 사탕 게임 (0) | 2024.11.15 |
---|---|
[ 백준 / C++ ] 5014 : 스타트링크 (0) | 2024.11.14 |
[ 백준 / C++ ] 1946 : 신입 사원 (0) | 2024.11.12 |
[ 백준 / C++ ] 18352 : 특정 거리의 도시 찾기 (0) | 2024.11.11 |
[ 백준 / C++ ] 1655 : 가운데를 말해요 (0) | 2024.11.08 |