답안 #826246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826246 2023-08-15T11:31:59 Z loctildore 분수 공원 (IOI21_parks) C++17
5 / 100
511 ms 69216 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
int n;
vector<int> u, v, a, b;
map<pair<int, int>, int> mp;
set<pair<int, int>> done;

vector<pair<int, int>> dirs = {{0, 2}, {2, 0}, {0, -2}, {-2, 0}};
vector<pair<int, int>> bloc[2] = {{{-1, 1}, {1, 1}, {1, -1}, {-1, -1}}, {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}}};

void dfs(int x, int y, int ldir = 0) {
    done.insert({x, y});
    for (int i = 0; i < 4; i++) {
        int ndir = (ldir + 3 + i) % 4;
        int nx = x + dirs[ndir].f;
        int ny = y + dirs[ndir].s;
        if (mp.find({nx, ny}) == mp.end()) continue;
        if (done.find({nx, ny}) != done.end()) continue;

        int tx = x + bloc[0][ndir].f;
        int ty = y + bloc[0][ndir].s;
        if (done.find({tx, ty}) == done.end()) {
            u.push_back(mp[{x, y}]);
            v.push_back(mp[{nx, ny}]);
            done.insert({tx, ty});
            a.push_back(tx);
            b.push_back(ty);
            dfs(nx, ny, ndir);
            continue;
        }

        tx = x + bloc[1][ndir].f;
        ty = y + bloc[1][ndir].s;
        if (done.find({tx, ty}) == done.end()) {
            u.push_back(mp[{x, y}]);
            v.push_back(mp[{nx, ny}]);
            done.insert({tx, ty});
            a.push_back(tx);
            b.push_back(ty);
            dfs(nx, ny, ndir);
        }
    }
}

int construct_roads(vector<int> xs, vector<int> ys) {
    srand(6969);
    n = xs.size();
    for (int i = 0; i < n; i++) {
        mp[{xs[i], ys[i]}] = i;
    }
    for (int tst = 0; tst < 7; tst++) {
        dfs(xs[rand() % n], ys[rand() % n]);
        if (u.size() == n - 1) {
            build(u, v, a, b);
            return 1;
        }
        done.clear();
        u.clear();
        v.clear();
        a.clear();
        b.clear();
    }
    return 0;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:60:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |         if (u.size() == n - 1) {
      |             ~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 4 ms 372 KB Output is correct
23 Correct 511 ms 58952 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 9 ms 852 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 188 ms 23848 KB Output is correct
29 Correct 265 ms 39536 KB Output is correct
30 Correct 373 ms 45900 KB Output is correct
31 Correct 437 ms 69216 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Incorrect 0 ms 212 KB Solution announced impossible, but it is possible.
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 4 ms 372 KB Output is correct
23 Correct 511 ms 58952 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 9 ms 852 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 188 ms 23848 KB Output is correct
29 Correct 265 ms 39536 KB Output is correct
30 Correct 373 ms 45900 KB Output is correct
31 Correct 437 ms 69216 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Incorrect 0 ms 212 KB Solution announced impossible, but it is possible.
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Incorrect 122 ms 15828 KB Solution announced impossible, but it is possible.
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
17 Correct 420 ms 69212 KB Output is correct
18 Correct 390 ms 63044 KB Output is correct
19 Incorrect 119 ms 15816 KB Solution announced impossible, but it is possible.
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 195 ms 30492 KB Output is correct
10 Correct 14 ms 3428 KB Output is correct
11 Correct 106 ms 16216 KB Output is correct
12 Correct 21 ms 5052 KB Output is correct
13 Correct 247 ms 10704 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 200 ms 30688 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 4 ms 372 KB Output is correct
23 Correct 511 ms 58952 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 596 KB Output is correct
26 Correct 9 ms 852 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 188 ms 23848 KB Output is correct
29 Correct 265 ms 39536 KB Output is correct
30 Correct 373 ms 45900 KB Output is correct
31 Correct 437 ms 69216 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Incorrect 0 ms 212 KB Solution announced impossible, but it is possible.
41 Halted 0 ms 0 KB -