fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int N;
  9. cin >> N;
  10. string S_S, S_K, S_H;
  11. cin >> S_S >> S_K >> S_H;
  12.  
  13. string S = S_S; // 처음엔 숭돌이 답안으로 맞춰둠
  14. int idx = -1;
  15.  
  16. for (int i = 0; i < N; i++) {
  17. // 조건: 숭돌이와 고돌이 다름 + 고돌이와 한돌이 다름
  18. if (S_S[i] != S_K[i] && S_K[i] != S_H[i]) {
  19. idx = i;
  20. break;
  21. }
  22. }
  23.  
  24. if (idx == -1) {
  25. cout << -1 << "\n";
  26. return 0;
  27. }
  28.  
  29. // 해당 위치를 고돌이 답으로 바꿔준다
  30. S[idx] = S_K[idx];
  31. cout << S << "\n";
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5320KB
stdin
5
abcde
efgtb
abgte
stdout
ebcde