Submission #481476

# Submission time Handle Problem Language Result Execution time Memory
481476 2021-10-21T02:43:47 Z yungyao Fountain Parks (IOI21_parks) C++17
0 / 100
1 ms 204 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,-2,0,0},dy[4] = {0,0,2,-2};
map <pii,bool> vis;

void dfs(int x,int y){
    vis[mkp(x,y)] = true;
    REP0(i,4) if (vis.find(mkp(x+dx[i],y+dy[i])) != vis.end() and !vis[mkp(x+dx[i],y+dy[i])]){
        dfs(x+dx[i],y+dy[i]);
    }
}

int construct_roads(vi x,vi y){
    int n = x.size();
    vi u,v,fx,fy;
    if (n == 1) return false;

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

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

    map <pii,int> mp;
    REP0(i,n) mp[mkp(x[i],y[i])] = i;

    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Solution announced impossible, but it is possible.
2 Halted 0 ms 0 KB -