//素直に実装。場合分けでも解けるけど、素朴に実装したほうが速かった。 #include #include using namespace std; int h, w; string s[100]; int main() { int i, j; cin >> h >> w; for (i = 0; i < h; i++) cin >> s[i]; int sy, sx; int gy, gx; int state = 0; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (s[i][j] == '*') { if (!state) { sy = i; sx = j; state++; } else { gy = i; gx = j; } } } } for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (s[i][j] == '*') continue; if ((sy - i) * (gx - j) == (gy - i) * (sx - j)) continue; s[i][j] = '*'; break; } if (j < w) break; } for (i = 0; i < h; i++) { cout << s[i] << endl; } return 0; }