# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159976 | 44442 | Konj (COCI19_konj) | C++11 | 16 ms | 8952 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;
int n,ax[200004],ay[200004],bx[200004],by[200004],c,d,v[304][304],x,y,a,b,f[304][304],minn,maxx,MINN,MAXX,ok=1,t,tt,aa,aaa,bb,bbb,ca,da,ii,jj,ox,oy,kx,ky;
bool k[304][304],vis[200004];
deque<int>kor;
pair<int,int>p,r,h[304][304],g[400004];
int main (){
ios::sync_with_stdio(0);
scanf("%d",&n);
minn=504;
MINN=504;
for(int i=1;i<n+1;i++){
scanf("%d %d %d %d\n", &ax[i],&ay[i],&bx[i],&by[i]);
p=make_pair(ax[i],ay[i]);
r=make_pair(bx[i],by[i]);
if(!h[ax[i]][ay[i]].first){
g[ok]=p;
ok++;
h[ax[i]][ay[i]]=make_pair(1,ok-1);
}
if(!h[bx[i]][by[i]].first){
g[ok]=r;
ok++;
h[bx[i]][by[i]]=make_pair(1,ok-1);
}
t=h[ax[i]][ay[i]].second;
tt=h[bx[i]][by[i]].second;
k[t][tt]=1;
k[tt][t]=1;
}
scanf("%d %d",&c,&d);
p=make_pair(c,d);
jj=h[c][d].second;
for(int i=1;i<n+1;i++){
ox=min(ax[i],bx[i]);
kx=max(ax[i],bx[i]);
oy=min(ay[i],by[i]);
ky=max(ay[i],by[i]);
if(ax[i]==bx[i]){
if(ax[i]==c and (oy<d and d<ky)){
kor.push_back(h[ax[i]][ay[i]].second);
}
}
else{
if(ay[i]==d and (ox<c and c<kx)){
kor.push_back(h[ax[i]][ay[i]].second);
}
}
}
kor.push_front(jj);
while(!kor.empty()){
ii=kor.front();
kor.pop_front();
if(!vis[ii]){
for(int j=0;j<ok+1;j++){
if(k[ii][j]){
a=g[ii].first;
b=g[ii].second;
ca=g[j].first;
da=g[j].second;
v[a][b]=1;
v[ca][da]=1;
kor.push_back(j);
aa=min(a,ca);
aaa=max(a,ca);
bb=min(b,da);
bbb=max(b,da);
minn=min(minn,bb);
maxx=max(maxx,bbb);
MINN=min(MINN,aa);
MAXX=max(MAXX,aaa);
}
}
vis[ii]=1;
}
}
for(int i=1;i<n+1;i++){
if(v[ax[i]][ay[i]]){
if(ay[i]==by[i]){
c=min(ax[i],bx[i]);
d=max(ax[i],bx[i]);
for(int j=c;j<d+1;j++){
f[j][ay[i]]=1;
}
}
else{
c=min(ay[i],by[i]);
d=max(ay[i],by[i]);
for(int j=c;j<d+1;j++){
f[ax[i]][j]=1;
}
}
}
}
for(int i=maxx;i>minn-1;i--){
for(int j=MINN;j<MAXX+1;j++){
if(f[j][i]){
printf("#");
}
else{
printf(".");
}
}
printf("\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |