Submission #218151

# Submission time Handle Problem Language Result Execution time Memory
218151 2020-04-01T10:28:50 Z extraterrestrial Airline Route Map (JOI18_airline) C++14
22 / 100
1218 ms 7416 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()

void Alice(int N, int M, int A[], int B[]) {
	InitG(2 * N + 2, M + (N + 2) * (N + 1) / 2 + N * (N + 1) / 2);
  int ptr = 0;
  for (int i = 0; i < M; i++) {
    MakeG(ptr++, A[i], B[i]);
  }
  for (int i = N + 1; i <= 2 * N + 2; i++) {
    for (int j = i + 1; j <= 2 * N + 2; j++) {
      MakeG(ptr++, i - 1, j - 1);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = N; j <= N + i; j++) {
      MakeG(ptr++, i, j);
    }
  }
}

#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 dfs(int v, vector<bool> &used, vector<int> &comp, vector<vector<int>> &g) {
  comp.pb(v);
  used[v] = true;
  for (auto u : g[v]) {
    if (!used[u]) {
      dfs(u, used, comp, g);
    }
  }
}

vector<int> get_clique(vector<int> &have, vector<vector<bool>> &ok) {
  vector<int> rez;
  for (int mask = 1; mask < (1 << (SZ(have))); mask++) {
    bool can = true;
    for (int i = 0; i < SZ(have); i++) {
      if ((mask >> i) & 1) {
        int v = have[i];
        for (int j = i + 1; j < SZ(have); j++) {
          if ((mask >> j) & 1) {
            int u = have[j];
            if (!ok[u][v]) {
              can = false;
            }
          }
        }
      }
    }
    if (can && __builtin_popcount(mask) > SZ(rez)) {
      rez = {};
      for (int i = 0; i < SZ(have); i++) {
        if ((mask >> i) & 1) {
          rez.pb(have[i]);
        }
      }
    }
  }  
  return rez;
}

void Bob(int V, int U, int C[], int D[]) {
  vector<bool> used(V);
  vector<vector<int>> g(V);
  vector<vector<bool>> ok(V, vector<bool>(V));
  for (int i = 0; i < U; i++) {
    g[C[i]].pb(D[i]);
    g[D[i]].pb(C[i]);
    ok[C[i]][D[i]] = ok[D[i]][C[i]] = true;
  }
  vector<int> comp, cl;
  for (int i = 0; i < V; i++) {
    if (!used[i]) {
      comp = {};
      dfs(i, used, comp, g);
      vector<int> rez = get_clique(comp, ok);
      if (SZ(rez) > SZ(cl)) {
        cl = rez;
      }
    }
  }
  InitMap(V - SZ(cl), U - SZ(cl) * (SZ(cl) - 1) / 2 - (V - SZ(cl)) * (V - SZ(cl) + 1) / 2);
  vector<bool> in_clique(V);
  for (auto it : cl) {
    in_clique[it] = true;
  }
  vector<int> id(V + 1);
  for (int i = 0; i < V; i++) {
    if (!in_clique[i]) {
      int cnt = 0;
      for (auto u : g[i]) {
        if (in_clique[u]) {
          cnt++;
        }
      }
      id[i] = cnt;
    }
  }
  for (int v = 0; v < V; v++) {
    for (int u : g[v]) {
      if (id[v] && id[u] && id[v] < id[u]) {
        //cerr << id[v] << ' ' << id[u] << endl;
        MakeMap(id[v] - 1, id[u] - 1);
      }
    }
  }
}

# Verdict Execution time Memory Grader output
1 Correct 1202 ms 6912 KB Output is correct
2 Correct 1194 ms 6912 KB Output is correct
3 Correct 1199 ms 6912 KB Output is correct
4 Correct 1195 ms 6912 KB Output is correct
5 Correct 1208 ms 6912 KB Output is correct
6 Correct 1209 ms 6912 KB Output is correct
7 Correct 1199 ms 6912 KB Output is correct
8 Correct 1199 ms 6912 KB Output is correct
9 Correct 1198 ms 6912 KB Output is correct
10 Correct 1187 ms 6912 KB Output is correct
11 Correct 1189 ms 6912 KB Output is correct
12 Correct 1200 ms 6912 KB Output is correct
13 Correct 1194 ms 6912 KB Output is correct
14 Correct 1205 ms 6912 KB Output is correct
15 Correct 1205 ms 6912 KB Output is correct
16 Correct 1201 ms 6912 KB Output is correct
17 Correct 1191 ms 6912 KB Output is correct
18 Correct 1205 ms 6912 KB Output is correct
19 Correct 1201 ms 6912 KB Output is correct
20 Correct 1203 ms 6912 KB Output is correct
21 Correct 281 ms 6912 KB Output is correct
22 Correct 73 ms 6912 KB Output is correct
23 Correct 277 ms 6912 KB Output is correct
24 Correct 26 ms 6912 KB Output is correct
25 Correct 16 ms 6912 KB Output is correct
26 Correct 16 ms 6912 KB Output is correct
27 Correct 26 ms 6912 KB Output is correct
28 Correct 277 ms 6800 KB Output is correct
29 Correct 74 ms 6912 KB Output is correct
30 Correct 73 ms 6912 KB Output is correct
31 Correct 1205 ms 6912 KB Output is correct
32 Correct 1186 ms 6912 KB Output is correct
33 Correct 1206 ms 6912 KB Output is correct
34 Correct 1188 ms 6912 KB Output is correct
35 Correct 1200 ms 6912 KB Output is correct
36 Correct 1202 ms 6912 KB Output is correct
37 Correct 1210 ms 6912 KB Output is correct
38 Correct 1218 ms 6912 KB Output is correct
39 Correct 1194 ms 6912 KB Output is correct
40 Correct 1194 ms 6912 KB Output is correct
41 Correct 1198 ms 6912 KB Output is correct
42 Correct 1202 ms 6912 KB Output is correct
43 Correct 1213 ms 6912 KB Output is correct
44 Correct 1205 ms 6912 KB Output is correct
45 Correct 1189 ms 6912 KB Output is correct
46 Correct 1214 ms 6912 KB Output is correct
47 Correct 1211 ms 6912 KB Output is correct
48 Correct 1193 ms 6912 KB Output is correct
49 Correct 1201 ms 6912 KB Output is correct
50 Correct 1217 ms 7168 KB Output is correct
51 Correct 13 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6656 KB Output is correct
54 Correct 13 ms 6912 KB Output is correct
55 Correct 14 ms 6912 KB Output is correct
56 Correct 13 ms 6912 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 14 ms 6912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1202 ms 6912 KB Output is correct
2 Correct 1194 ms 6912 KB Output is correct
3 Correct 1199 ms 6912 KB Output is correct
4 Correct 1195 ms 6912 KB Output is correct
5 Correct 1208 ms 6912 KB Output is correct
6 Correct 1209 ms 6912 KB Output is correct
7 Correct 1199 ms 6912 KB Output is correct
8 Correct 1199 ms 6912 KB Output is correct
9 Correct 1198 ms 6912 KB Output is correct
10 Correct 1187 ms 6912 KB Output is correct
11 Correct 1189 ms 6912 KB Output is correct
12 Correct 1200 ms 6912 KB Output is correct
13 Correct 1194 ms 6912 KB Output is correct
14 Correct 1205 ms 6912 KB Output is correct
15 Correct 1205 ms 6912 KB Output is correct
16 Correct 1201 ms 6912 KB Output is correct
17 Correct 1191 ms 6912 KB Output is correct
18 Correct 1205 ms 6912 KB Output is correct
19 Correct 1201 ms 6912 KB Output is correct
20 Correct 1203 ms 6912 KB Output is correct
21 Correct 281 ms 6912 KB Output is correct
22 Correct 73 ms 6912 KB Output is correct
23 Correct 277 ms 6912 KB Output is correct
24 Correct 26 ms 6912 KB Output is correct
25 Correct 16 ms 6912 KB Output is correct
26 Correct 16 ms 6912 KB Output is correct
27 Correct 26 ms 6912 KB Output is correct
28 Correct 277 ms 6800 KB Output is correct
29 Correct 74 ms 6912 KB Output is correct
30 Correct 73 ms 6912 KB Output is correct
31 Correct 1205 ms 6912 KB Output is correct
32 Correct 1186 ms 6912 KB Output is correct
33 Correct 1206 ms 6912 KB Output is correct
34 Correct 1188 ms 6912 KB Output is correct
35 Correct 1200 ms 6912 KB Output is correct
36 Correct 1202 ms 6912 KB Output is correct
37 Correct 1210 ms 6912 KB Output is correct
38 Correct 1218 ms 6912 KB Output is correct
39 Correct 1194 ms 6912 KB Output is correct
40 Correct 1194 ms 6912 KB Output is correct
41 Correct 1198 ms 6912 KB Output is correct
42 Correct 1202 ms 6912 KB Output is correct
43 Correct 1213 ms 6912 KB Output is correct
44 Correct 1205 ms 6912 KB Output is correct
45 Correct 1189 ms 6912 KB Output is correct
46 Correct 1214 ms 6912 KB Output is correct
47 Correct 1211 ms 6912 KB Output is correct
48 Correct 1193 ms 6912 KB Output is correct
49 Correct 1201 ms 6912 KB Output is correct
50 Correct 1217 ms 7168 KB Output is correct
51 Correct 13 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6656 KB Output is correct
54 Correct 13 ms 6912 KB Output is correct
55 Correct 14 ms 6912 KB Output is correct
56 Correct 13 ms 6912 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 14 ms 6912 KB Output is correct
59 Incorrect 607 ms 6912 KB Wrong Answer [10]
60 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 401 ms 7416 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -