답안 #465695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465695 2021-08-16T16:34:42 Z alexxela12345 분수 공원 (IOI21_parks) C++17
15 / 100
863 ms 52792 KB
#include <bits/stdc++.h>
#include "parks.h"

using namespace std;

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    map<pair<int, int>, int> byc;
    int n = x.size();
    for (int i = 0; i < n; i++) {
      byc[{x[i], y[i]}] = i;
    }
    vector<int> u, v, a, b;
    vector<vector<int>> g(n);
    auto add = [&](int i, int j) {
      if (i < j) {
	g[i].push_back(j);
	g[j].push_back(i);
        u.push_back(i);
        v.push_back(j);
        if (x[i] != x[j]) {
	  a.push_back((x[i] + x[j]) / 2);
	  b.push_back(y[i] + 1);
        } else {
	  b.push_back((y[i] + y[j]) / 2);
	  if (x[i] == 2) {
	    a.push_back(1);
          } else {
            a.push_back(5);
          }
        }
      }
    };

    for (int i = 0; i < n; i++) {
      {
        pair<int, int> pp = {x[i], y[i]};
        pp.first += 2;
        if (byc.count(pp)) {
          add(i, byc[pp]);
        }
      }
      {
        pair<int, int> pp = {x[i], y[i]};
        pp.second += 2;
        if (byc.count(pp)) {
          add(i, byc[pp]);
        }
      }
      {
        pair<int, int> pp = {x[i], y[i]};
        pp.first -= 2;
        if (byc.count(pp)) {
          add(i, byc[pp]);
        }
      }
      {
        pair<int, int> pp = {x[i], y[i]};
        pp.second -= 2;
        if (byc.count(pp)) {
          add(i, byc[pp]);
        }
      }
    }
    vector<int> used(n);
    function<void(int)> dfs;
    dfs = [&](int v) {
      used[v] = 1;
      for (int u : g[v]) {
        if (!used[u]) {
          dfs(u);
        }
      }
    };
    dfs(0);
    if (*min_element(used.begin(), used.end()) == 0) {
      return 0;
    }
    build(u, v, a, b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 838 ms 52792 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 3 ms 588 KB Output is correct
26 Correct 5 ms 844 KB Output is correct
27 Correct 6 ms 972 KB Output is correct
28 Correct 259 ms 21640 KB Output is correct
29 Correct 466 ms 30228 KB Output is correct
30 Correct 661 ms 41304 KB Output is correct
31 Correct 863 ms 51712 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 3 ms 588 KB Output is correct
44 Correct 4 ms 812 KB Output is correct
45 Correct 292 ms 23440 KB Output is correct
46 Correct 489 ms 34072 KB Output is correct
47 Correct 477 ms 33824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 838 ms 52792 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 3 ms 588 KB Output is correct
26 Correct 5 ms 844 KB Output is correct
27 Correct 6 ms 972 KB Output is correct
28 Correct 259 ms 21640 KB Output is correct
29 Correct 466 ms 30228 KB Output is correct
30 Correct 661 ms 41304 KB Output is correct
31 Correct 863 ms 51712 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 3 ms 588 KB Output is correct
44 Correct 4 ms 812 KB Output is correct
45 Correct 292 ms 23440 KB Output is correct
46 Correct 489 ms 34072 KB Output is correct
47 Correct 477 ms 33824 KB Output is correct
48 Incorrect 0 ms 292 KB Tree @(5, 3) appears more than once: for edges on positions 0 and 1
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
17 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (5, 3) is not adjacent to edge between u[0]=0 @(200000, 2) and v[0]=1 @(200000, 4)
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
17 Incorrect 690 ms 49664 KB Tree (a[2], b[2]) = (5, 52499) is not adjacent to edge between u[2]=1 @(100002, 52498) and v[2]=117727 @(100002, 52500)
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 263 ms 24352 KB Output is correct
10 Correct 15 ms 2764 KB Output is correct
11 Correct 96 ms 13568 KB Output is correct
12 Correct 23 ms 3972 KB Output is correct
13 Correct 52 ms 8888 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 266 ms 21840 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 838 ms 52792 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 3 ms 588 KB Output is correct
26 Correct 5 ms 844 KB Output is correct
27 Correct 6 ms 972 KB Output is correct
28 Correct 259 ms 21640 KB Output is correct
29 Correct 466 ms 30228 KB Output is correct
30 Correct 661 ms 41304 KB Output is correct
31 Correct 863 ms 51712 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 3 ms 588 KB Output is correct
44 Correct 4 ms 812 KB Output is correct
45 Correct 292 ms 23440 KB Output is correct
46 Correct 489 ms 34072 KB Output is correct
47 Correct 477 ms 33824 KB Output is correct
48 Incorrect 0 ms 292 KB Tree @(5, 3) appears more than once: for edges on positions 0 and 1
49 Halted 0 ms 0 KB -