# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105132 | leonarda | Konj (COCI19_konj) | C++14 | 116 ms | 12628 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 pb push_back
#define mp make_pair
typedef pair<int, int> pi;
int n, tx, ty;
vector<pi> m[300 + 5][300 + 5];
bool memo[300 + 5][300 + 5];
queue<int> qx, qy;
char crtez[300 + 5][300 + 5];
int minix = 0x3f3f3f3f, maksx = 0, miniy = 0x3f3f3f3f, maksy = 0;
vector<pi> v1, v2;
void crtaj(int x, int y) {
for(int i = 0; i < m[x][y].size(); ++i) {
int u = m[x][y][i].first;
int v = m[x][y][i].second;
minix = min(minix, u);
maksx = max(maksx, u);
miniy = min(miniy, v);
maksy = max(maksy, v);
if(u == x) {
for(int j = min(y, v); j <= max(y, v); ++j)
crtez[x][j] = '#';
} else if(y == v) {
for(int j = min(u, x); j <= max(u, x); ++j) {
crtez[j][y] = '#';
}
}
}
return;
}
int main ()
{
ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; ++i) {
int a, b, c, d;
cin >> a >> b >> c >> d;
v1.pb(mp(a, b)); v2.pb(mp(c, d));
m[a][b].pb(mp(c, d));
m[c][d].pb(mp(a, b));
}
cin >> tx >> ty;
for(int i = 0; i < n; ++i) {
if(v1[i].first == v2[i].first) {
if(tx == v1[i].first and ty >= min(v1[i].second, v2[i].second) and ty <= max(v1[i].second, v2[i].second)) {
qx.push(v1[i].first); qy.push(v1[i].second);
qx.push(v2[i].first); qy.push(v2[i].second);
}
} else if(v1[i].second == v2[i].second) {
if(ty == v1[i].second and tx >= min(v1[i].first, v2[i].first) and tx <= max(v1[i].first, v2[i].first)) {
qx.push(v1[i].first); qy.push(v1[i].second);
qx.push(v2[i].first); qy.push(v2[i].second);
}
}
}
while(!qx.empty()) {
int x = qx.front();
int y = qy.front();
qx.pop(); qy.pop();
if(memo[x][y] == 1) continue;
else {
for(int i = 0; i < m[x][y].size(); ++i) {
qx.push(m[x][y][i].first);
qy.push(m[x][y][i].second);
}
memo[x][y] = 1;
}
}
for(int i = 0; i <= 304; ++i) {
for(int j = 0; j <= 304; ++j) {
if(memo[i][j]) {
crtaj(i, j);
maksx = max(maksx, i);
maksy = max(maksy, j);
minix = min(minix, i);
miniy = min(miniy, j);
}
}
}
for(int i = maksy; i >= miniy; --i) {
if(i != maksy) cout << endl;
for(int j = minix; j <= maksx; ++j) {
if(crtez[j][i] == '#') cout << crtez[j][i];
else cout << '.';
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |