# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100300 |
2019-03-10T10:10:25 Z |
kraljlavova1 |
Konj (COCI19_konj) |
C++11 |
|
58 ms |
5112 KB |
#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 |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
58 ms |
5112 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Incorrect |
3 ms |
532 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |