# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147261 | ipaljak | Konj (COCI19_konj) | C++14 | 78 ms | 760 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;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
typedef long long llint;
const int MOD = 1e9 + 7;
const int MAXN = 605;
const int dr[] = {0, -1, 0, 1};
const int ds[] = {1, 0, -1, 0};
int n, D = 600;
char grid[MAXN][MAXN];
void draw(int a, int b, int c, int d) {
for (int i = min(a, c); i <= max(a, c); ++i)
for (int j = min(b, d); j <= max(b, d); ++j)
grid[i][j] = '*';
}
void print() {
int minr = D, maxr = 0, mins = D, maxs = 0;
for (int i = 0; i <= D; ++i) {
for (int j = 0; j <= D; ++j) {
if (grid[i][j] == '#') {
minr = min(minr, i);
maxr = max(maxr, i);
mins = min(mins, j);
maxs = max(maxs, j);
}
}
}
for (int i = minr; i <= maxr; i += 2) {
for (int j = mins; j <= maxs; j += 2) {
if (grid[i][j] == '*') grid[i][j] = '.';
printf("%c", grid[i][j]);
}
printf("\n");
}
}
inline bool check(int r, int s) {
return r >= 0 && r <= D && s >= 0 && s <= D && grid[r][s] == '*';
}
int main(void) {
scanf("%d", &n);
memset(grid, '.', sizeof grid);
for (int i = 0; i < n; ++i) {
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
b = D / 2 - b; d = D / 2 - d;
a *= 2; b *= 2; c *= 2; d *= 2;
draw(b, a, d, c);
}
int r, s;
scanf("%d%d", &r, &s);
s = D / 2 - s;
r *= 2; s *= 2;
swap(r, s);
queue<pair<int, int>> Q;
Q.push({r, s});
grid[r][s] = '#';
while (!Q.empty()) {
auto p = Q.front();
Q.pop();
for (int i = 0; i < 4; ++i) {
int _r = p.first + dr[i];
int _s = p.second + ds[i];
if (!check(_r, _s)) continue;
grid[_r][_s] = '#';
Q.push({_r, _s});
}
}
print();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |