#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d, x, y;
int U=1000, D, L=1000 ,R;
char konj[305][305]; bool v[305][305];
void dfs(int x, int y){
v[x][y]=1;
U = min(U,x);
D = max(D,x);
L = min(L,y);
R = max(R,y);
if (x-1>=0 and !v[x-1][y] and konj[x-1][y]=='#') dfs(x-1,y);
if (y-1>=0 and !v[x][y-1] and konj[x][y-1]=='#') dfs(x,y-1);
if (!v[x+1][y] and konj[x+1][y]=='#') dfs(x+1,y);
if (!v[x][y+1] and konj[x][y+1]=='#') dfs(x,y+1);
return;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
for (int i=0;i<=301;i++){
for (int j=0;j<=301;j++){
konj[i][j]='.';
}
}
cin >> n;
for (int i=0;i<n;i++){
cin >> a >> b >> c >> d;
for (int i=min(a,c);i<=max(a,c);i++){
for (int j=min(b,d);j<=max(b,d);j++){
konj[j][i]='#';
}
}
}
cin >> x >> y;
dfs(y,x);
for (int i=D;i>=U;i--){
for (int j=L;j<=R;j++){
if (v[i][j]) cout << '#';
else cout << '.';
}
cout << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
68 ms |
9208 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
540 KB |
Output is correct |