Submission #100310

#TimeUsernameProblemLanguageResultExecution timeMemory
100310tpoppoKonj (COCI19_konj)C++14
70 / 70
63 ms1144 KiB
#include <bits/stdc++.h> using namespace std; int n; using pii = pair<int,int>; vector<pii> rot = {{0,-1},{0,1},{-1,0},{1,0}}; char mat[400][400]; bool dir[400][400][4]; void draw_point(int a,int b,int c,int d){ if(d == b){ for(int x = min(a,c);x<=max(a,c);x++){ mat[x][b] = '@'; if(x != min(a,c)) dir[x][b][2] = true; if(x != max(a,c)) dir[x][b][3] = true; } } if(a == c){ for(int y = min(b,d);y<=max(b,d);y++){ mat[a][y] = '@'; if(y != min(b,d)) dir[a][y][0] = true; if(y != max(b,d)) dir[a][y][1] = true; } } } int mixp = 1e9; int miyp = 1e9; int maxp = -1e9; int mayp = -1e9; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; memset(mat,'.',sizeof(mat)); for(int i=0;i<n;i++){ int a,b,c,d; cin >> a >> b >> c >> d; b = 305 - b; d = 305 - d; draw_point(a,b,c,d); /* for(int i=280;i<=300;i++){ for(int j=10;j<=60;j++){ cout<< mat[j][i]; }cout<<'\n'; } */ } int x,y; cin >> x >> y; y = 305 - y; queue<pii> coda; coda.push({x,y}); do{ auto cima = coda.front(); coda.pop(); if(cima.first < 0 || cima.second < 0) continue; if(mat[cima.first][cima.second] != '@') continue; mat[cima.first][cima.second] = '#'; mixp = min(mixp,cima.first); maxp = max(maxp,cima.first); miyp = min(miyp,cima.second); mayp = max(mayp,cima.second); for(int i=0;i<4;i++){ auto el = rot[i]; //cout<<cima.first<<" "<<cima.second<<" => "<<dir[cima.first][cima.second][i]<<" "<< mat[cima.first + el.first][cima.second + el.second] <<endl; if(dir[cima.first][cima.second][i]){ coda.push({el.first + cima.first, el.second + cima.second}); } } }while(!coda.empty()); for(int i=miyp;i<=mayp;i++){ for(int j=mixp;j<=maxp;j++){ cout<< (mat[j][i]=='@'?'.':mat[j][i]); }cout<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...