QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524626#1142. Fountain ParksMousa_Aboubaker#0 141ms42948kbC++204.2kb2024-08-19 21:27:322024-08-19 21:27:32

Judging History

你现在查看的是最新测评结果

  • [2024-08-19 21:27:32]
  • 评测
  • 测评结果:0
  • 用时:141ms
  • 内存:42948kb
  • [2024-08-19 21:27:32]
  • 提交

answer

#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

int construct_roads(std::vector<int> X, std::vector<int> Y)
{
    vector<int> dx{0, 0, 2, -2}, dy{2, -2, 0, 0};
    set<pair<int, int>> locations;
    for (int i = 0; i < X.size(); i++)
    {
        locations.insert({X[i], Y[i]});
    }
    auto dfs = [&](auto self, int x, int y) -> void
    {
        locations.erase({x, y});
        for (int i = 0; i < 4; i++)
        {
            if (locations.find({x + dx[i], y + dy[i]}) != locations.end())
            {
                self(self, x + dx[i], y + dy[i]);
            }
        }
    };
    dfs(dfs, X.front(), Y.front());

    if (!locations.empty())
    {
        return 0;
    }

    int n = X.size() - 1;
    vector<int> u, v, a, b;
    vector<tuple<int, int, int>> cord;
    for (int i = 0; i < n + 1; i++)
    {
        cord.push_back({X[i], Y[i], i});
    }
    sort(cord.begin(), cord.end());
    map<pair<int, int>, bool> vis;
    int cnt = 0;
    auto dfs2 = [&](auto self, int i) -> void
    {
        auto [x, y, id] = cord[i];
        vis[{x, y}] = true;
        if (x == 2)
        {
            {
                int idx = lower_bound(cord.begin(), cord.end(), make_tuple(x, y + 2, -1)) - cord.begin();
                if (idx - 1 != n)
                {
                    auto [xx, yy, idid] = cord[idx];
                    if (xx == x and yy == y + 2)
                    {
                        if (!vis[{xx, yy}])
                        {
                            u.push_back(id);
                            v.push_back(idid);
                            a.push_back(1);
                            b.push_back(y + 1);
                            self(self, idid);
                        }
                    }
                }
            }
            {
                int idx = lower_bound(cord.begin(), cord.end(), make_tuple(x + 2, y, -1)) - cord.begin();
                if (idx - 1 != n)
                {
                    auto [xx, yy, idid] = cord[idx];
                    if (xx == x + 2 and yy == y)
                    {
                        if (!vis[{xx, yy}])
                        {
                            u.push_back(id);
                            v.push_back(idid);
                            a.push_back(3);
                            b.push_back(y - 1);
                            self(self, idid);
                        }
                    }
                }
            }
        }
        else
        {
            {
                int idx = lower_bound(cord.begin(), cord.end(), make_tuple(x, y + 2, -1)) - cord.begin();
                if (idx - 1 != n)
                {
                    auto [xx, yy, idid] = cord[idx];
                    if (xx == x and yy == y + 2)
                    {
                        if (!vis[{xx, yy}])
                        {
                            u.push_back(id);
                            v.push_back(idid);
                            a.push_back(5);
                            b.push_back(y + 1);
                            self(self, idid);
                        }
                    }
                }
            }
            
            {
                int idx = lower_bound(cord.begin(), cord.end(), make_tuple(x - 2, y, -1)) - cord.begin();
                if (idx - 1 != n)
                {
                    auto [xx, yy, idid] = cord[idx];
                    if (xx == x - 2 and yy == y)
                    {
                        if (!vis[{xx, yy}])
                        {
                            u.push_back(id);
                            v.push_back(idid);
                            a.push_back(3);
                            b.push_back(y - 1);
                            self(self, idid);
                        }
                    }
                }
            }
        }
    };
    dfs2(dfs2, 0);
    build(u, v, a, b);
    // for (int i = 0; i < u.size(); i++)
    // {
    //     cout << u[i] << ' ' << v[i] << ' ' << a[i] << ' ' << b[i] << '\n';
    // }
    return 1;
}
// void build(std::vector<int> u, std::vector<int> v, std::vector<int> a, std::vector<int> b);

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3784kb

input:

ba73dbf9c7d5e5202834d6a500541c
1
2 2

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
0

result:

ok 

Test #2:

score: 5
Accepted
time: 0ms
memory: 4064kb

input:

ba73dbf9c7d5e5202834d6a500541c
2
2 2
2 4

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
1
0 1 1 3

result:

ok 

Test #3:

score: 5
Accepted
time: 0ms
memory: 3788kb

input:

ba73dbf9c7d5e5202834d6a500541c
2
2 2
2 6

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

ok 

Test #4:

score: 5
Accepted
time: 0ms
memory: 3808kb

input:

ba73dbf9c7d5e5202834d6a500541c
3
2 2
2 4
2 6

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
2
0 1 1 3
1 2 1 5

result:

ok 

Test #5:

score: 5
Accepted
time: 0ms
memory: 4036kb

input:

ba73dbf9c7d5e5202834d6a500541c
4
2 2
2 4
2 6
2 8

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
3
0 1 1 3
1 2 1 5
2 3 1 7

result:

ok 

Test #6:

score: 5
Accepted
time: 0ms
memory: 3880kb

input:

ba73dbf9c7d5e5202834d6a500541c
3
2 2
2 4
2 8

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

ok 

Test #7:

score: 5
Accepted
time: 0ms
memory: 3736kb

input:

ba73dbf9c7d5e5202834d6a500541c
4
2 2
2 4
2 8
2 10

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

ok 

Test #8:

score: 5
Accepted
time: 0ms
memory: 4084kb

input:

ba73dbf9c7d5e5202834d6a500541c
4
2 2
2 4
2 6
2 10

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

ok 

Test #9:

score: 0
Wrong Answer
time: 57ms
memory: 22104kb

input:

ba73dbf9c7d5e5202834d6a500541c
100000
2 15660
2 23918
2 132200
2 117654
2 162750
2 183010
2 75554
2 29740
2 185476
2 135138
2 194024
2 182274
2 1338
2 42922
2 51616
2 171196
2 159598
2 136432
2 84454
2 61806
2 136968
2 167442
2 150036
2 23974
2 10064
2 86342
2 146274
2 174318
2 130832
2 118838
2 180...

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
402
13952 31503 1 3
55140 51965 1 63009
65225 85319 1 103933
6100 89468 1 170641
51160 33055 1 178939
56408 55770 1 66113
96299 66143 1 111543
56889 53638 1 132289
52909 22994 1 107279
39203 66398 1 45991
86560 84039 1 132799
50526 15621 1 168081
45638 6...

result:

wrong answer Given structure is not connected: There is no path between vertices 0 and 1

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #82:

score: 0
Wrong Answer
time: 0ms
memory: 3780kb

input:

ba73dbf9c7d5e5202834d6a500541c
3
200000 2
200000 4
199998 2

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
0

result:

wrong answer Given structure is not connected: There is no path between vertices 0 and 1

Subtask #5:

score: 0
Wrong Answer

Test #108:

score: 0
Wrong Answer
time: 141ms
memory: 42948kb

input:

ba73dbf9c7d5e5202834d6a500541c
200000
82422 100002
100002 52498
82816 2
97624 2
100002 58032
20638 100002
100002 7646
80512 2
2 10584
28426 100002
2 83036
2 64556
47872 100002
55196 2
85350 100002
2 95376
2 23942
12488 100002
83178 2
2 9086
85598 2
100002 78820
100002 10868
98810 2
84182 100002
2 71...

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
810
199575 112394 1 3
101256 141430 3 100001
157488 179513 3 100001
79025 4496 5 59031
192927 40785 1 8995
102463 116152 1 81573
46726 164081 3 100001
52638 20938 5 28167
95887 130315 1 41879
24279 154877 3 1
115494 1016 5 9759
182005 124952 1 2035
13786...

result:

wrong answer Tree (a[1], b[1]) = (3, 100001) is not adjacent to edge between u[1]=101256 @(62396, 100002) and v[1]=141430 @(62394, 100002)

Subtask #6:

score: 0
Skipped

Dependency #1:

0%