# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100266 | ami | Konj (COCI19_konj) | C++14 | 93 ms | 7032 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>
#define sz(c) int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;
enum { UP, RIGHT, DOWN, LEFT };
int const MAXX=330;
bool can[MAXX][MAXX][4];
bool was[MAXX][MAXX];
void flood(int x,int y) {
if (was[x][y]) return;
was[x][y]=true;
if (can[x][y][UP]) flood(x,y+1);
if (can[x][y][DOWN]) flood(x,y-1);
if (can[x][y][RIGHT]) flood(x+1,y);
if (can[x][y][LEFT]) flood(x-1,y);
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cout<<fixed<<setprecision(10);
int n;
cin>>n;
rep(i,0,n) {
int a,b,c,d;
cin>>a>>b>>c>>d;
if (a>c || b>d) {
swap(a,c);
swap(b,d);
}
if (a==c) {
int x=a;
rep(y,b,d) can[x][y][UP]=can[x][y+1][DOWN]=true;
} else {
int y=b;
rep(x,a,c) can[x][y][RIGHT]=can[x+1][y][LEFT]=true;
}
}
{
int x,y;
cin>>x>>y;
flood(x,y);
}
int a=MAXX,b=MAXX,c=-MAXX,d=-MAXX;
rep(x,0,MAXX) rep(y,0,MAXX) if (was[x][y]) {
a=min(a,x);
b=min(b,y);
c=max(c,x);
d=max(d,y);
}
per(y,b,d+1) {
rep(x,a,c+1) cout<<(was[x][y]?'#':'.');
cout<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |