mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 06:38:48 +00:00
CF14A Letter
R40309333
This commit is contained in:
parent
ad296e7122
commit
05dba36899
32
problem/CF14A/CF14A.cpp
Normal file
32
problem/CF14A/CF14A.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n, m;
|
||||
int minx = 0x3f3f3f, miny = 0x3f3f3f;
|
||||
int maxx = 0x000000, maxy = 0x000000;
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user