# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100604 | kraljlavova1 | Konj (COCI19_konj) | C++11 | 85 ms | 10232 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, idx;
int tx, ty;
int a, b, c, d;
int xmx, ymx, xmn = MAX, ymn = MAX;
int bio[MAX][MAX];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
char P[MAX][MAX];
vector<int> duz[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(bio[nx][ny]) continue;
for(int p : duz[x][y]){
for(int q : duz[nx][ny]){
if(p == q){
dfs(nx, ny);
goto G;
}
}
}
G:;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n;
while(n--){
cin >> a >> b >> c >> d;
if(a > c) swap(a, c);
if(b > d) swap(b, d);
for(int i = a;i <= c; i++){
for(int j = b;j <= d; j++){
duz[i][j].push_back(idx);
}
}idx++;
}
cin >> tx >> ty;
dfs(tx, ty);
for(int i = 0;i < MAX; i++){
for(int j = 0;j < MAX; j++){
if(!bio[i][j]) continue;
xmx = max(xmx, i);
xmn = min(xmn, i);
ymx = max(ymx, j);
ymn = min(ymn, j);
}
}
for(int i = 0;i < MAX; i++){
for(int j = 0;j < MAX; j++){
if(bio[i][j]) P[i][j] = '#';
else P[i][j] = '.';
}
}
for(int j = ymx;j >= ymn; j--){
for(int i = xmn;i <= xmx; i++){
cout << P[i][j];
}
cout << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |