답안 #218447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218447 2020-04-02T07:40:02 Z extraterrestrial 항공 노선도 (JOI18_airline) C++14
22 / 100
681 ms 35384 KB
#include "Alicelib.h"
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()

//InitG(n, m)
//MakeG(id, u, v)

void Alice(int N, int M, int A[], int B[]) {
	vector<pair<int, int>> edges;
  for (int i = 0; i < M; i++) {
    edges.pb({A[i], B[i]});
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 10; j++) {
      if ((i >> j) & 1) {
        edges.pb({i - 1, N + j});
      }
    }
  }
  for (int j = 0; j < 9; j++) {
    edges.pb({N + j, N + j + 1});
  }
  for (int i = 0; i < N; i++) {
    edges.pb({i, N + 10});
  }
  for (int i = 0; i < N + 10; i++) {
    edges.pb({i, N + 11});
  }
  InitG(N + 12, SZ(edges));
  for (int i = 0; i < SZ(edges); i++) {
    MakeG(i, edges[i].F, edges[i].S);
  }
}

#include "Boblib.h"
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()

void Bob(int V, int U, int C[], int D[]) {
  int n = V - 12;
  pair<int, int> mx;
  vector<int> cnt(V);
  vector<vector<int>> g(V);
  for (int i = 0; i < U; i++) {
    cnt[C[i]]++;
    cnt[D[i]]++;
    g[C[i]].pb(D[i]);
    g[D[i]].pb(C[i]);
  }
  for (int i = 0; i < V; i++) {
    mx = max(mx, make_pair(cnt[i], i));
  }
  assert(mx.F == n + 10);
  vector<bool> used(V);
  for (auto it : g[mx.S]) {
    used[it] = true;
  }
  int id = -1;
  for (int i = 0; i < V; i++) {
    if (!used[i] && i != mx.S) {
      id = i;
    }
  }
  assert(id != -1);
  fill(all(used), false);
  for (auto it : g[id]) {
    used[it] = true;
  }
  int fst = -1;
  for (int i = 0; i < V; i++) {
    if (!used[i] && i != id && i != mx.S) {
      int cc = 0;
      for (auto it : g[i]) {
        if (!used[it] && it != id && it != mx.S) {
          cc++;
        }
      }
      if (cc == 1) {
        fst = i;
        break;
      }
    }
  }
  int prv = 0, cur = fst;
  vector<int> path = {cur};
  for (int i = 0; i < 9; i++) {
    for (auto it : g[cur]) {
      if (!used[it] && it != id && it != mx.S && it != prv) {
        path.pb(it);
        prv = cur;
        cur = it;
        break;
      }
    }
  }
  if (cnt[path[0]] < cnt[path.back()]) {
    reverse(all(path));
  }
  vector<vector<bool>> ok(10, vector<bool>(V));
  for (int i = 0; i < 10; i++) {
    for (auto it : g[path[i]]) {
      ok[i][it] = true;
    }
  }
  vector<pair<int, int>> rez;
  vector<int> go(V);
  for (int i = 0; i < V; i++) {
    if (used[i]) {
      int vl = 0;
      for (int j = 0; j < 10; j++) {
        if (ok[j][i]) {
          vl += 1 << j;
        }
      }
      vl--;
      go[i] = vl;
    }
  }
  for (int i = 0; i < U; i++) {
    if (used[C[i]] && used[D[i]]) {
      rez.pb({go[C[i]], go[D[i]]});
    }
  }
  InitMap(n, SZ(rez));
  for (auto it : rez) {
    MakeMap(it.F, it.S);
  }  
}

# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 6912 KB Output is correct
2 Correct 13 ms 6912 KB Output is correct
3 Correct 13 ms 6912 KB Output is correct
4 Correct 13 ms 6912 KB Output is correct
5 Correct 13 ms 6912 KB Output is correct
6 Correct 13 ms 6912 KB Output is correct
7 Correct 13 ms 6912 KB Output is correct
8 Correct 13 ms 6816 KB Output is correct
9 Correct 13 ms 6912 KB Output is correct
10 Correct 13 ms 6912 KB Output is correct
11 Correct 13 ms 6912 KB Output is correct
12 Correct 13 ms 6912 KB Output is correct
13 Correct 13 ms 6864 KB Output is correct
14 Correct 13 ms 6760 KB Output is correct
15 Correct 13 ms 6912 KB Output is correct
16 Correct 13 ms 6912 KB Output is correct
17 Correct 13 ms 6912 KB Output is correct
18 Correct 13 ms 6912 KB Output is correct
19 Correct 13 ms 6912 KB Output is correct
20 Correct 14 ms 6912 KB Output is correct
21 Correct 13 ms 6912 KB Output is correct
22 Correct 14 ms 6912 KB Output is correct
23 Correct 13 ms 6912 KB Output is correct
24 Correct 13 ms 6656 KB Output is correct
25 Correct 13 ms 6912 KB Output is correct
26 Correct 13 ms 6912 KB Output is correct
27 Correct 13 ms 6912 KB Output is correct
28 Correct 13 ms 6912 KB Output is correct
29 Correct 13 ms 6912 KB Output is correct
30 Correct 13 ms 6912 KB Output is correct
31 Correct 13 ms 6656 KB Output is correct
32 Correct 13 ms 6912 KB Output is correct
33 Correct 13 ms 6656 KB Output is correct
34 Correct 13 ms 6912 KB Output is correct
35 Correct 13 ms 6912 KB Output is correct
36 Correct 15 ms 6912 KB Output is correct
37 Correct 13 ms 6912 KB Output is correct
38 Correct 13 ms 6912 KB Output is correct
39 Correct 13 ms 6912 KB Output is correct
40 Correct 14 ms 6912 KB Output is correct
41 Correct 14 ms 6912 KB Output is correct
42 Correct 13 ms 6912 KB Output is correct
43 Correct 13 ms 6912 KB Output is correct
44 Correct 13 ms 6912 KB Output is correct
45 Correct 13 ms 6912 KB Output is correct
46 Correct 13 ms 6888 KB Output is correct
47 Correct 13 ms 6912 KB Output is correct
48 Correct 13 ms 6912 KB Output is correct
49 Correct 13 ms 6912 KB Output is correct
50 Correct 13 ms 6912 KB Output is correct
51 Correct 14 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6912 KB Output is correct
54 Correct 15 ms 6912 KB Output is correct
55 Correct 13 ms 6912 KB Output is correct
56 Correct 14 ms 6912 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 13 ms 6912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 6912 KB Output is correct
2 Correct 13 ms 6912 KB Output is correct
3 Correct 13 ms 6912 KB Output is correct
4 Correct 13 ms 6912 KB Output is correct
5 Correct 13 ms 6912 KB Output is correct
6 Correct 13 ms 6912 KB Output is correct
7 Correct 13 ms 6912 KB Output is correct
8 Correct 13 ms 6816 KB Output is correct
9 Correct 13 ms 6912 KB Output is correct
10 Correct 13 ms 6912 KB Output is correct
11 Correct 13 ms 6912 KB Output is correct
12 Correct 13 ms 6912 KB Output is correct
13 Correct 13 ms 6864 KB Output is correct
14 Correct 13 ms 6760 KB Output is correct
15 Correct 13 ms 6912 KB Output is correct
16 Correct 13 ms 6912 KB Output is correct
17 Correct 13 ms 6912 KB Output is correct
18 Correct 13 ms 6912 KB Output is correct
19 Correct 13 ms 6912 KB Output is correct
20 Correct 14 ms 6912 KB Output is correct
21 Correct 13 ms 6912 KB Output is correct
22 Correct 14 ms 6912 KB Output is correct
23 Correct 13 ms 6912 KB Output is correct
24 Correct 13 ms 6656 KB Output is correct
25 Correct 13 ms 6912 KB Output is correct
26 Correct 13 ms 6912 KB Output is correct
27 Correct 13 ms 6912 KB Output is correct
28 Correct 13 ms 6912 KB Output is correct
29 Correct 13 ms 6912 KB Output is correct
30 Correct 13 ms 6912 KB Output is correct
31 Correct 13 ms 6656 KB Output is correct
32 Correct 13 ms 6912 KB Output is correct
33 Correct 13 ms 6656 KB Output is correct
34 Correct 13 ms 6912 KB Output is correct
35 Correct 13 ms 6912 KB Output is correct
36 Correct 15 ms 6912 KB Output is correct
37 Correct 13 ms 6912 KB Output is correct
38 Correct 13 ms 6912 KB Output is correct
39 Correct 13 ms 6912 KB Output is correct
40 Correct 14 ms 6912 KB Output is correct
41 Correct 14 ms 6912 KB Output is correct
42 Correct 13 ms 6912 KB Output is correct
43 Correct 13 ms 6912 KB Output is correct
44 Correct 13 ms 6912 KB Output is correct
45 Correct 13 ms 6912 KB Output is correct
46 Correct 13 ms 6888 KB Output is correct
47 Correct 13 ms 6912 KB Output is correct
48 Correct 13 ms 6912 KB Output is correct
49 Correct 13 ms 6912 KB Output is correct
50 Correct 13 ms 6912 KB Output is correct
51 Correct 14 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6912 KB Output is correct
54 Correct 15 ms 6912 KB Output is correct
55 Correct 13 ms 6912 KB Output is correct
56 Correct 14 ms 6912 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 13 ms 6912 KB Output is correct
59 Correct 16 ms 6912 KB Output is correct
60 Correct 16 ms 6912 KB Output is correct
61 Correct 13 ms 6912 KB Output is correct
62 Correct 13 ms 6912 KB Output is correct
63 Correct 13 ms 6912 KB Output is correct
64 Correct 13 ms 6912 KB Output is correct
65 Correct 14 ms 6912 KB Output is correct
66 Correct 14 ms 6912 KB Output is correct
67 Correct 13 ms 6912 KB Output is correct
68 Correct 13 ms 6912 KB Output is correct
69 Correct 13 ms 6912 KB Output is correct
70 Correct 13 ms 6912 KB Output is correct
71 Correct 13 ms 6912 KB Output is correct
72 Correct 14 ms 6912 KB Output is correct
73 Correct 13 ms 6912 KB Output is correct
74 Correct 13 ms 6912 KB Output is correct
75 Correct 13 ms 6912 KB Output is correct
76 Correct 14 ms 6912 KB Output is correct
77 Correct 14 ms 6912 KB Output is correct
78 Correct 14 ms 6912 KB Output is correct
79 Correct 14 ms 6912 KB Output is correct
80 Correct 13 ms 6912 KB Output is correct
81 Runtime error 15 ms 6912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
82 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 681 ms 35384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -