답안 #151447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151447 2019-09-03T08:18:39 Z dolphingarlic Konj (COCI19_konj) C++14
70 / 70
70 ms 9592 KB
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;
 
enum { UP, RIGHT, DOWN, LEFT };
 
int const MAXX=330;
bool can[MAXX][MAXX][4];
bool was[MAXX][MAXX];
 
void flood(int x,int y) {
	if (was[x][y]) return;
 
	was[x][y]=true;
	if (can[x][y][UP])    flood(x,y+1);
	if (can[x][y][DOWN])  flood(x,y-1);
	if (can[x][y][RIGHT]) flood(x+1,y);
	if (can[x][y][LEFT])  flood(x-1,y);
}
 
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);
 
	int n;
	cin>>n;
	rep(i,0,n) {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
 
		if (a>c || b>d) {
			swap(a,c);
			swap(b,d);
		}
 
		if (a==c) {
			int x=a;
			rep(y,b,d) can[x][y][UP]=can[x][y+1][DOWN]=true;
		} else {
			int y=b;
			rep(x,a,c) can[x][y][RIGHT]=can[x+1][y][LEFT]=true;
		}
	}
 
	{	
		int x,y;
		cin>>x>>y;
		flood(x,y);
	}
 
	int a=MAXX,b=MAXX,c=-MAXX,d=-MAXX;
	rep(x,0,MAXX) rep(y,0,MAXX) if (was[x][y]) {
		a=min(a,x);
		b=min(b,y);
		c=max(c,x);
		d=max(d,y);
	}
 
	per(y,b,d+1) {
		rep(x,a,c+1) cout<<(was[x][y]?'#':'.');
		cout<<"\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 70 ms 9592 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct