정답 코드
#include <iostream>
#include <algorithm>
using namespace std;
string a, b;
char puz[31][31];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int idx_x=31, idx_y=31;
cin>>a>>b;
for(int i=0; i<a.size(); i++) {
for(int j=0; j<b.size(); j++) {
if(a[i] == b[j]) {
if(i<=idx_x && j<=idx_y) {
idx_x=i;
idx_y=j;
break;
}
}
}
}
for(int i=0; i<a.size(); i++) {
puz[idx_y][i] = a[i];
}
for(int i=0; i<b.size(); i++) {
puz[i][idx_x] = b[i];
}
for(int i=0; i<b.size(); i++) {
for(int j=0; j<a.size(); j++) {
if(puz[i][j]) {
cout<<puz[i][j];
}
else {
cout<<'.';
}
}
cout<<'\n';
}
return 0;
}