Submission #101194

#TimeUsernameProblemLanguageResultExecution timeMemory
101194mayhoubsalehKonj (COCI19_konj)C++14
56 / 70
419 ms24764 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; int n,a[200005][4]; map<pair<int,int>,vector<int>>m; map<pair<int,int>,bool>vis; int l=1e3,r=-1,up=-1,down=1e3; bool c[333][333]; void add(int id){ for(int i=a[id][0];i<=a[id][2];i++){ for(int j=a[id][1];j<=a[id][3];j++){ c[i][j]=1; up=max(up,i); down=min(down,i); l=min(l,j);r=max(r,j); } } } void dfs(int x,int y){ if(vis[{x,y}])return; vis[{x,y}]=1; for(auto i:m[{x,y}]){ add(i); dfs(a[i][0],a[i][1]); dfs(a[i][2],a[i][3]); } } int main(){ cin>>n; for(int i=0;i<n;i++){ for(int j=0;j<4;j++){ cin>>a[i][j]; } if(a[i][0]>a[i][2])swap(a[i][0],a[i][2]); if(a[i][1]>a[i][3])swap(a[i][1],a[i][3]); m[{a[i][0],a[i][1]}].pb(i); m[{a[i][2],a[i][3]}].pb(i); } int x,y; cin>>x>>y; for(int i=0;i<n;i++){ if(a[i][0]==a[i][2]){ if(y>=a[i][1]&&y<=a[i][3])dfs(a[i][0],a[i][1]),dfs(a[i][2],a[i][3]); } else{ if(x>=a[i][0]&&x<=a[i][2])dfs(a[i][0],a[i][1]),dfs(a[i][2],a[i][3]); } } for(int i=r;i>=l;i--){ for(int j=down;j<=up;j++){ if(c[j][i])cout<<'#'; else cout<<'.'; } cout<<endl; } return 0; } //ofstream fout("planting.out"); //ifstream fin("planting.in");
#Verdict Execution timeMemoryGrader output
Fetching results...