Submission #570760

#TimeUsernameProblemLanguageResultExecution timeMemory
570760AGEKonj (COCI19_konj)C++14
0 / 70
1067 ms25932 KiB
#include<bits/stdc++.h> #define F first #define S second #define pb push_back #define int long long using namespace std; const int N=1e6,M=2e3; int maxx,maxy,minx,miny; int a[N],b[N],c[N],d[N]; map< pair<int,int>, int> vis; map< pair<int,int> , vector< pair<int,int> > > adj; int ans[301][301]; void dfs(int xnode,int ynode){ vis[{xnode,ynode}]=1; for(auto x:adj[{xnode,ynode}]){ if(vis[x]==1) continue; dfs(x.F,x.S); } } main() { int n; cin>>n; maxx=-1e18,minx=1e18,maxy=-1e18,miny=1e18; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]>>c[i]>>d[i]; adj[{a[i],b[i]}].pb({c[i],d[i]}); } int x,y; cin>>x>>y; ans[x][y]=1; for(int i=0;i<n;i++){ for(int j=min(a[i],b[i]);j<=max(a[i],b[i]);j++){ for(int k=min(c[i],d[i]);k<=max(c[i],d[i]);k++){ if(j==x&&k==y) dfs(min(a[i],b[i]),min(c[i],d[i])),dfs(max(a[i],b[i]),max(c[i],d[i])); } } } for(int i=0;i<n;i++){ if(!vis[{min(a[i],c[i]),min(b[i],d[i])}]&&!vis[{max(a[i],c[i]),max(b[i],d[i])}]) continue; minx=min(minx,min(a[i],b[i])); miny=min(miny,min(c[i],d[i])); maxx=max(maxx,max(a[i],b[i])); maxy=max(maxy,max(c[i],d[i])); for(int j=min(a[i],c[i]);j<=max(a[i],c[i]);j++){ for(int k=min(b[i],d[i]);k<=max(b[i],d[i]);k++){ ans[j][k]=1; } } } for(int j=maxy;j>=miny;j--){ for(int i=minx;i<=maxx;i++){ if(ans[i][j]==1) cout<<"#"; else cout<<"."; } cout<<endl; } return 0; } /* 2 2 6 2 2 2 2 6 6 2 6 4 6 4 6 6 2 6 6 6 6 2 8 2 8 2 10 2 10 2 12 2 12 2 12 4 12 4 6 4 6 2 6 1 8 2 8 0 10 2 10 1 12 2 12 0 42 42 42 43 2 2 */

Compilation message (stderr)

konj.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...