본문 바로가기

PS

[ 백준 / C++ ] 11328 : Strfry

[ 문제 ]

 

11328번: Strfry

 

[ 접근방법 ]

 

입력마다 소문자 개수를 체크하여 비교한다.

 

[ 소스코드 ]

 

#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;
}