-
11328) Strfry c++백준코딩일기 2020. 10. 17. 07:37
문제 ) www.acmicpc.net/problem/11328
풀이 )
N 번의 테스트 케이스를 돌리면서 입력을 받고,
fill(input, input+26, 0) 행을 통해서 input배열에 0으로 모두 초기화 한다.
input 배열은 문자가 있는지 비교한다.코드 )
#include <iostream> using namespace std; int N, input[26]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool check; string s1, s2; cin >> N; for (int i = 0; i < N; i++) { cin >> s1 >> s2; check = true; fill(input, input + 26, 0); for (int j = 0; j < s1.length(); j++) { input[s1[j] - 'a']++; input[s2[j] - 'a']--; } for (int j = 0; j < 26; j++) { if (input[j] != 0) { check = false; break; } } if (check) cout << "Possible\n"; else cout << "Impossible\n"; } }
'백준코딩일기' 카테고리의 다른 글
1919) 애너그램 만들기 c++ (0) 2020.10.17 13300) 방 배정 c++ (0) 2020.10.17 2577) 숫자의 개수 (0) 2020.10.17 10807) 개수 세기 c++ (0) 2020.10.17 10808) 알파벳 개수 C++ (0) 2020.10.16