# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100363 | MatesV13 | Konj (COCI19_konj) | C++11 | 68 ms | 9208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |