답안 #481495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481495 2021-10-21T03:47:00 Z yungyao 분수 공원 (IOI21_parks) C++17
0 / 100
2476 ms 2097156 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>

typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define REP(n) for (int __=n;__--;)
#define REP1(i,n) for (int i=1;i<=n;++i)
#define REP0(i,n) for (int i=0;i<n;++i)
typedef vector <int> vi;

#include "parks.h"

int dx[4] = {2,0,-2,0},dy[4] = {0,2,0,-2};
int dfx[8] = {1,1,1,-1,-1,-1,-1,1}, dfy[8] = {-1,1,1,1,1,-1,-1,-1};
map <pii,bool> vis;

vi u,v,fx,fy;
set <pii> ben;
map <pii,int> mp;
void dfs(int x,int y){
    vis[mkp(x,y)] = true;
    int fr = -1;
    REP0(i,4) if (vis.find(mkp(x+dx[i],y+dy[i])) != vis.end()){
        if (vis[mkp(x+dx[i],y+dy[i])]) fr = i;
    }

    int c = 0;
    for(int i=(fr+1)%4;c<4;i=(i+1)%4,++c) if (vis.find(mkp(x+dx[i],y+dy[i])) != vis.end()){
        u.pb(mp[mkp(x,y)]);
        v.pb(mp[mkp(x+dx[i],y+dy[i])]);
        if (ben.find(mkp(x+dfx[i*2],y+dfy[i*2])) == ben.end()){
            ben.insert(mkp(x+dfx[i*2],y+dfy[i*2]));
            fx.pb(x+dfx[i*2]);
            fy.pb(y+dfy[i*2]);
        }
        else{
            ben.insert(mkp(x+dfx[i*2+1],y+dfy[i*2+1]));
            fx.pb(x+dfx[i*2+1]);
            fy.pb(y+dfy[i*2+1]);
        }
        dfs(x+dx[i],y+dy[i]);
    }
}

int construct_roads(vi x,vi y){
    int n = x.size();

    REP0(i,n) vis[mkp(x[i],y[i])] = false;
    REP0(i,n) mp[mkp(x[i],y[i])] = i;
    dfs(x[0],y[0]);

    for (auto [p,v]:vis) if (!v) return false;


    /*
    REP0(i,n){
        if (mp.find(mkp(x[i]+2,y[i])) != mp.end()){
            u.pb(i);
            v.pb(mp[mkp(x[i]+2,y[i])]);
            fx.pb(3);
            fy.pb(y[i]-1);
        }

        if (mp.find(mkp(x[i],y[i]+2)) != mp.end()){
            u.pb(i);
            v.pb(mp[mkp(x[i],y[i]+2)]);
            if (x[i] == 2) fx.pb(1);
            else fx.pb(5);
            fy.pb(y[i]+1);
        }
    }
    */

    build(u,v,fx,fy);
    return true;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 2476 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -