PS/BOJ
[백준] 11328. Strfry(c++)
backend 개발자 지망생
2025. 1. 19. 18:50
https://www.acmicpc.net/problem/11328
조금 마음에 들진 않지만,간편하게 인덱스를 문자로 받고 싶어서 map을 썼다.
배열로 쓰려면 아스키코드 문자를 이용해서 인덱스를 지정하면 될 듯하다.
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
string temp;
string temp2;
while (n--) {
bool flag = true;
map<char, int> first_string;
map<char, int> second_string;
cin >> temp;
for (char i: temp) {
first_string[i]++;
}
cin >> temp2;
for (char i: temp2) {
second_string[i]++;
}
if (temp.size() == temp2.size()) {
for (char i: temp) {
if (first_string[i] != second_string[i]) {
flag = false;
cout << "Impossible\n";
break;
}
}
if (flag) {
cout << "Possible\n";
}
} else {
cout << "Impossible" << "\n";
}
}
return 0;
}