# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100300 | kraljlavova1 | Konj (COCI19_konj) | C++11 | 58 ms | 5112 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;
typedef long long int ll;
typedef pair<int, int> pii;
const int MAX = 3e2 + 10;
int n, a, b, c, d, tx, ty;
int xmx, ymx, xmn = MAX, ymn = MAX;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int bio[MAX][MAX];
char P[MAX][MAX];
void dfs(int x, int y){
bio[x][y] = 1;
for(int i = 0;i < 4; i++){
int nx = x + dx[i];
int ny = y + dy[i];
if(nx < 0 || nx >= MAX) continue;
if(ny < 0 || ny >= MAX) continue;
if(P[x][y] == 'S' && P[nx][ny] == '#'){
if(!bio[nx][ny]) dfs(nx, ny);
}
else if(P[nx][ny] == '#' ||P[nx][ny] == 'S'){
if(!bio[nx][ny]) dfs(nx, ny);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n;
for(int i = 0;i < MAX; i++){
for(int j = 0;j < MAX; j++){
P[i][j] = '.';
}
}
for(int i = 0;i < n; i++){
cin >> a >> b >> c >> d;
if(a > c) swap(a, c);
if(b > d) swap(b, d);
for(int j = a;j <= c; j++){
for(int k = b; k <= d; k++){
if(j == a && k == c) P[j][k] = 'S';
else if(j == b && k == d) P[j][k] = 'S';
else P[j][k] = '#';
}
}
}
cin >> tx >> ty;
dfs(tx, ty);
for(int i = 0;i < MAX; i++){
for(int j = 0;j < MAX; j++){
if(bio[i][j]){
P[i][j] = '#';
xmx = max(xmx, i);
xmn = min(xmn, i);
ymx = max(ymx, j);
ymn = min(ymn, j);
}
else P[i][j] = '.';
}
}
for(int j = ymn;j <= ymx; j++){
for(int i = xmn;i <= xmx; i++){
cout << P[i][ymx - (j - ymn)];
}
cout << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |