답안 #655687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655687 2022-11-05T09:57:44 Z KiriLL1ca Political Development (BOI17_politicaldevelopment) C++17
0 / 100
712 ms 31188 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pw(x) (1ll << x)
#define sz(x) (int)((x).size())
#define pb push_back
#define endl '\n'
#define mp make_pair
#define vec vector

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef unsigned long long ull;
typedef unsigned int uint;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T>
using oset = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void solve () {
        const int N = 50005;
        int n, k; cin >> n >> k;
        vector <vector <int>> g (n);
        vector <bitset <N>> bt (n);
        for (int i = 0; i < n; ++i) {
                int k; cin >> k;
                while (k--) {
                        int x; cin >> x;
                        g[i].pb(x); bt[i][x] = 1;
                }
        }
        int ans = 0;
        for (int i = 0; i < n; ++i) {
                if (sz(g[i]) <= ans) continue;
                for (int msk = 0; msk < pw(sz(g[i])); ++msk) {
                        if (__builtin_popcount(msk) + 1 <= ans) continue;
                        bitset <N> need; need[i] = 1;
                        for (int j = 0; j < sz(g[i]); ++j) if (msk >> j & 1) need[g[i][j]] = 1;
                        bool ok = 1;
                        for (int j = 0; j < sz(g[i]); ++j) {
                                need[g[i][j]] = 0;
                                ok &= (need == (bt[g[i][j]] & need));
                                need[g[i][j]] = 1;
                        }
                        if (ok) umax(ans, __builtin_popcount(msk) + 1);
                }
        }
        cout << ans << endl;
}

signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #ifdef LOCAL
                freopen("input.txt", "r", stdin);
                freopen("output.txt", "w", stdout);
        #endif
        int t = 1; // cin >> t;
        while (t--) solve();
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 216 ms 31156 KB Output is correct
4 Correct 552 ms 31188 KB Output is correct
5 Correct 555 ms 31188 KB Output is correct
6 Correct 711 ms 31128 KB Output is correct
7 Correct 712 ms 31188 KB Output is correct
8 Incorrect 13 ms 30932 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 216 ms 31156 KB Output is correct
4 Correct 552 ms 31188 KB Output is correct
5 Correct 555 ms 31188 KB Output is correct
6 Correct 711 ms 31128 KB Output is correct
7 Correct 712 ms 31188 KB Output is correct
8 Incorrect 13 ms 30932 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 31044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 216 ms 31156 KB Output is correct
4 Correct 552 ms 31188 KB Output is correct
5 Correct 555 ms 31188 KB Output is correct
6 Correct 711 ms 31128 KB Output is correct
7 Correct 712 ms 31188 KB Output is correct
8 Incorrect 13 ms 30932 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 216 ms 31156 KB Output is correct
4 Correct 552 ms 31188 KB Output is correct
5 Correct 555 ms 31188 KB Output is correct
6 Correct 711 ms 31128 KB Output is correct
7 Correct 712 ms 31188 KB Output is correct
8 Incorrect 13 ms 30932 KB Output isn't correct
9 Halted 0 ms 0 KB -