Submission #159812

#TimeUsernameProblemLanguageResultExecution timeMemory
15981244442Konj (COCI19_konj)C++11
63 / 70
171 ms65540 KiB
#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,ox,oy,kx,ky; deque<pair<int,int> >s[304][304]; deque<int>korx,kory; pair<int,int>p,r; 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]); s[ax[i]][ay[i]].push_back(r); s[bx[i]][by[i]].push_back(p); } scanf("%d %d",&c,&d); korx.push_back(c); kory.push_back(d); 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)){ korx.push_back(ax[i]); kory.push_back(ay[i]); } } else{ if(ay[i]==d and (ox<c and c<kx)){ korx.push_back(ax[i]); kory.push_back(ay[i]); } } } while(!korx.empty()){ x=korx.front(); y=kory.front(); while(!s[x][y].empty()){ a=s[x][y].front().first; b=s[x][y].front().second; if(!v[a][b]){ korx.push_back(a); kory.push_back(b); minn=min(minn,b); maxx=max(maxx,b); MINN=min(MINN,a); MAXX=max(MAXX,a); v[a][b]=1; } s[x][y].pop_front(); } korx.pop_front(); kory.pop_front(); } 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)

konj.cpp: In function 'int main()':
konj.cpp:10:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d",&n);
      ~~~~~^~~~~~~~~
konj.cpp:14:12: 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:20:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d %d",&c,&d);
 ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...