답안 #100310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100310 2019-03-10T11:06:42 Z tpoppo Konj (COCI19_konj) C++14
70 / 70
63 ms 1144 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 63 ms 1144 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 768 KB Output is correct