답안 #655795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655795 2022-11-05T15:04:38 Z KiriLL1ca Political Development (BOI17_politicaldevelopment) C++17
4 / 100
5 ms 1236 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 () {
        int n, k; cin >> n >> k;
        vector <int> cnt (n);
        vector <set <int>> g (n);
        set <pii> s;
        for (int i = 0; i < n; ++i) {
                cin >> cnt[i];
                for (int j = 0; j < cnt[i]; ++j) {
                        int x; cin >> x;
                        g[i].insert(x);
                }
                s.insert({cnt[i], i});
        }
        int ans = 0;
        for (auto [_, i] : s) {
                if (!_) continue;
                vector <int> ar;
                for (auto j : g[i]) ar.pb(j);

                for (int msk = 0; msk < pw(sz(ar)); ++msk) {
                        if (__builtin_popcount(msk) <= ans) continue;
                        vector <int> b;
                        for (int j = 0; j < sz(ar); ++j) if (msk >> j & 1) b.pb(ar[j]);
                        bool okich = 1;
                        for (int i = 0; i < sz(ar) && okich; ++i) {
                                for (int j = i + 1; j < sz(ar) && okich; ++j) {
                                        if (g[ar[i]].find(ar[j]) == g[ar[i]].end()) okich = 0;
                                }
                        }
                        if (okich) umax(ans, __builtin_popcount(msk));
                }

                for (auto j : g[i]) {
                        s.erase({cnt[j], j});
                        --cnt[j]; g[j].erase(i);
                        s.insert({cnt[j], j});
                }
        }
        cout << ans + 1 << 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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 700 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 4 ms 1236 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 5 ms 1236 KB Output is correct
7 Correct 5 ms 1236 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -