0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 02:18:51 +00:00
OI-codes/Luogu/CF14A/CF14A.cpp

33 lines
896 B
C++
Raw Normal View History

2020-10-22 13:38:50 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
2021-11-19 09:01:13 +00:00
int n, m;
int minx = 0x3f3f3f, miny = 0x3f3f3f;
int maxx = 0x000000, maxy = 0x000000;
2020-10-22 13:38:50 +00:00
string s[55];
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> s[i];
if (find(s[i].begin(), s[i].end(), '*') != s[i].end()) {
minx = min(minx, i);
miny = min(miny, (int)(s[i].find_first_of('*') == string::npos ? miny : s[i].find_first_of('*')));
maxy = max(maxy, (int)(s[i].find_last_of('*') == string::npos ? maxy : s[i].find_last_of('*')));
}
}
for (int i = n - 1; i >= 0; i--) {
if (s[i].find('*') != string::npos) {
maxx = i;
break;
}
}
for (int i = minx; i <= maxx; i++) {
for (int j = miny; j <= maxy; j++) {
cout << s[i][j];
}
cout << endl;
}
return 0;
}