====== Strfry ====== ===== 풀이 ===== * 두 스트링이 같은 글자들을 포함하는지를 비교하면 된다. * 쉬운 방법은 각각 스트링을 정렬한 다음에 일치하는지 보는 것이고, 다른 방법은 글자들마다 갯수를 세어서 그것을 비교하는 것이다. 전자는 정렬을 해야 하니 O(nlogn)이 걸리지만 후자는 O(n)으로도 가능하다. ===== 코드 ===== """Solution code for "BOJ 11328. Strfry". - Problem link: https://www.acmicpc.net/problem/11328 - Solution link: http://www.teferi.net/ps/problems/boj/11328 """ import collections import sys def main(): N = int(sys.stdin.readline()) for _ in range(N): str1, str2 = sys.stdin.readline().split() counter1 = collections.Counter(str1) counter2 = collections.Counter(str2) print('Possible' if counter1 == counter2 else 'Impossible') if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:브론즈_2}}