#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[400004];
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
konj.cpp: In function 'int main()':
konj.cpp:9:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
konj.cpp:13:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d %d\n", &ax[i],&ay[i],&bx[i],&by[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
konj.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&c,&d);
~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
632 KB |
Output is correct |
3 |
Runtime error |
16 ms |
9208 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
632 KB |
Output is correct |
6 |
Correct |
2 ms |
632 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
632 KB |
Output is correct |