Submission #838481

# Submission time Handle Problem Language Result Execution time Memory
838481 2023-08-27T08:09:15 Z Forested Political Development (BOI17_politicaldevelopment) C++17
16 / 100
3000 ms 524288 KB
#ifndef LOCAL
#define FAST_IO
#endif

// ============
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define OVERRIDE(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, m, n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)
#define ALL(x) begin(x), end(x)

using namespace std;

using u32 = unsigned int;
using u64 = unsigned long long;
using i32 = signed int;
using i64 = signed long long;
using f64 = double;
using f80 = long double;

template <typename T>
using Vec = vector<T>;

template <typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

#ifdef INT128

using u128 = __uint128_t;
using i128 = __int128_t;

istream &operator>>(istream &is, i128 &x) {
    i64 v;
    is >> v;
    x = v;
    return is;
}
ostream &operator<<(ostream &os, i128 x) {
    os << (i64)x;
    return os;
}
istream &operator>>(istream &is, u128 &x) {
    u64 v;
    is >> v;
    x = v;
    return is;
}
ostream &operator<<(ostream &os, u128 x) {
    os << (u64)x;
    return os;
}

#endif

[[maybe_unused]] constexpr i32 INF = 1000000100;
[[maybe_unused]] constexpr i64 INF64 = 3000000000000000100;
struct SetUpIO {
    SetUpIO() {
#ifdef FAST_IO
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
#endif
        cout << fixed << setprecision(15);
    }
} set_up_io;
// ============

#ifdef DEBUGF
#else
#define DBG(x) (void)0
#endif

int main() {
    i32 n, k;
    cin >> n >> k;
    Vec<Vec<i32>> edge(n, Vec<i32>(n, 0));
    Vec<i32> deg(n);
    REP(i, n) {
        cin >> deg[i];
        REP(j, deg[i]) {
            i32 v;
            cin >> v;
            edge[i][v] = 1;
        }
    }
    priority_queue<pair<i32, i32>, Vec<pair<i32, i32>>, greater<>> pq;
    REP(i, n) {
        pq.emplace(deg[i], i);
    }
    Vec<i32> alive(n, 1);
    i32 ans = 0;
    while (!pq.empty()) {
        auto [_, v] = pq.top();
        pq.pop();
        if (!alive[v]) {
            continue;
        }
        Vec<i32> lis;
        REP(u, n) {
            if (alive[u] && edge[v][u]) {
                lis.push_back(u);
            }
        }
        i32 d = (i32)lis.size();
        REP(st, 1 << d) {
            bool ok = true;
            REP(i, d) {
                if (!(st & (1 << i))) {
                    continue;
                }
                REP(j, i) {
                    if (!(st & (1 << j))) {
                        continue;
                    }
                    if (!edge[lis[i]][lis[j]]) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                chmax(ans, __builtin_popcount(st) + 1);
            }
        }
        alive[v] = 0;
        REP(u, n) {
            if (alive[u]) {
                pq.emplace(--deg[u], u);
            }
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1887 ms 229928 KB Output is correct
4 Correct 1285 ms 229876 KB Output is correct
5 Correct 1277 ms 230028 KB Output is correct
6 Correct 1455 ms 229836 KB Output is correct
7 Correct 1464 ms 229864 KB Output is correct
8 Correct 1387 ms 229860 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1440 ms 229868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1887 ms 229928 KB Output is correct
4 Correct 1285 ms 229876 KB Output is correct
5 Correct 1277 ms 230028 KB Output is correct
6 Correct 1455 ms 229836 KB Output is correct
7 Correct 1464 ms 229864 KB Output is correct
8 Correct 1387 ms 229860 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1440 ms 229868 KB Output is correct
11 Correct 1269 ms 229812 KB Output is correct
12 Correct 1298 ms 229840 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1302 ms 229824 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1464 ms 229948 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1466 ms 229908 KB Output is correct
19 Correct 1400 ms 229776 KB Output is correct
20 Correct 1434 ms 229780 KB Output is correct
21 Correct 1415 ms 229768 KB Output is correct
22 Correct 1402 ms 229824 KB Output is correct
23 Correct 1872 ms 229912 KB Output is correct
24 Correct 1431 ms 229836 KB Output is correct
25 Correct 1969 ms 229964 KB Output is correct
26 Correct 1891 ms 229828 KB Output is correct
27 Correct 1413 ms 229820 KB Output is correct
28 Correct 1892 ms 229876 KB Output is correct
29 Correct 1430 ms 229824 KB Output is correct
30 Correct 1758 ms 229864 KB Output is correct
31 Correct 1852 ms 229804 KB Output is correct
32 Correct 1750 ms 229884 KB Output is correct
33 Correct 1811 ms 229920 KB Output is correct
34 Correct 1810 ms 229820 KB Output is correct
35 Correct 435 ms 57908 KB Output is correct
36 Correct 431 ms 57892 KB Output is correct
37 Correct 438 ms 57888 KB Output is correct
38 Correct 91 ms 14752 KB Output is correct
39 Correct 91 ms 14780 KB Output is correct
40 Correct 1996 ms 229856 KB Output is correct
41 Correct 92 ms 14656 KB Output is correct
42 Correct 2028 ms 229948 KB Output is correct
43 Correct 1982 ms 229844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1389 ms 229764 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Runtime error 210 ms 524288 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1887 ms 229928 KB Output is correct
4 Correct 1285 ms 229876 KB Output is correct
5 Correct 1277 ms 230028 KB Output is correct
6 Correct 1455 ms 229836 KB Output is correct
7 Correct 1464 ms 229864 KB Output is correct
8 Correct 1387 ms 229860 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1440 ms 229868 KB Output is correct
11 Correct 1269 ms 229812 KB Output is correct
12 Correct 1298 ms 229840 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1302 ms 229824 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1464 ms 229948 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1466 ms 229908 KB Output is correct
19 Correct 1400 ms 229776 KB Output is correct
20 Correct 1434 ms 229780 KB Output is correct
21 Correct 1415 ms 229768 KB Output is correct
22 Correct 1402 ms 229824 KB Output is correct
23 Correct 1872 ms 229912 KB Output is correct
24 Correct 1431 ms 229836 KB Output is correct
25 Correct 1969 ms 229964 KB Output is correct
26 Correct 1891 ms 229828 KB Output is correct
27 Correct 1413 ms 229820 KB Output is correct
28 Correct 1892 ms 229876 KB Output is correct
29 Correct 1430 ms 229824 KB Output is correct
30 Correct 1758 ms 229864 KB Output is correct
31 Correct 1852 ms 229804 KB Output is correct
32 Correct 1750 ms 229884 KB Output is correct
33 Correct 1811 ms 229920 KB Output is correct
34 Correct 1810 ms 229820 KB Output is correct
35 Correct 435 ms 57908 KB Output is correct
36 Correct 431 ms 57892 KB Output is correct
37 Correct 438 ms 57888 KB Output is correct
38 Correct 91 ms 14752 KB Output is correct
39 Correct 91 ms 14780 KB Output is correct
40 Correct 1996 ms 229856 KB Output is correct
41 Correct 92 ms 14656 KB Output is correct
42 Correct 2028 ms 229948 KB Output is correct
43 Correct 1982 ms 229844 KB Output is correct
44 Correct 1556 ms 230008 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 2025 ms 229896 KB Output is correct
47 Correct 2116 ms 229932 KB Output is correct
48 Correct 2016 ms 229896 KB Output is correct
49 Correct 2144 ms 230144 KB Output is correct
50 Correct 2161 ms 230060 KB Output is correct
51 Execution timed out 3071 ms 230288 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1887 ms 229928 KB Output is correct
4 Correct 1285 ms 229876 KB Output is correct
5 Correct 1277 ms 230028 KB Output is correct
6 Correct 1455 ms 229836 KB Output is correct
7 Correct 1464 ms 229864 KB Output is correct
8 Correct 1387 ms 229860 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1440 ms 229868 KB Output is correct
11 Correct 1269 ms 229812 KB Output is correct
12 Correct 1298 ms 229840 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1302 ms 229824 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1464 ms 229948 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1466 ms 229908 KB Output is correct
19 Correct 1400 ms 229776 KB Output is correct
20 Correct 1434 ms 229780 KB Output is correct
21 Correct 1415 ms 229768 KB Output is correct
22 Correct 1402 ms 229824 KB Output is correct
23 Correct 1872 ms 229912 KB Output is correct
24 Correct 1431 ms 229836 KB Output is correct
25 Correct 1969 ms 229964 KB Output is correct
26 Correct 1891 ms 229828 KB Output is correct
27 Correct 1413 ms 229820 KB Output is correct
28 Correct 1892 ms 229876 KB Output is correct
29 Correct 1430 ms 229824 KB Output is correct
30 Correct 1758 ms 229864 KB Output is correct
31 Correct 1852 ms 229804 KB Output is correct
32 Correct 1750 ms 229884 KB Output is correct
33 Correct 1811 ms 229920 KB Output is correct
34 Correct 1810 ms 229820 KB Output is correct
35 Correct 435 ms 57908 KB Output is correct
36 Correct 431 ms 57892 KB Output is correct
37 Correct 438 ms 57888 KB Output is correct
38 Correct 91 ms 14752 KB Output is correct
39 Correct 91 ms 14780 KB Output is correct
40 Correct 1996 ms 229856 KB Output is correct
41 Correct 92 ms 14656 KB Output is correct
42 Correct 2028 ms 229948 KB Output is correct
43 Correct 1982 ms 229844 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Runtime error 167 ms 524288 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -