답안 #570763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570763 2022-05-31T08:58:00 Z AGE Konj (COCI19_konj) C++14
7 / 70
296 ms 26476 KB
#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],c[i]);j<=max(a[i],c[i]);j++){
            for(int k=min(b[i],d[i]);k<=max(b[i],d[i]);k++){

                if(j==x&&k==y)
                    dfs(min(a[i],c[i]),min(b[i],d[i])),dfs(max(a[i],c[i]),max(b[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],c[i]));
        miny=min(miny,min(b[i],d[i]));
        maxx=max(maxx,max(a[i],c[i]));
        maxy=max(maxy,max(b[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

konj.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Incorrect 296 ms 26476 KB Output isn't correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct