Submission #655703

# Submission time Handle Problem Language Result Execution time Memory
655703 2022-11-05T10:35:00 Z KiriLL1ca Political Development (BOI17_politicaldevelopment) C++17
4 / 100
3000 ms 5332 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);
        for (int i = 0; i < n; ++i) {
                int k; cin >> k;
                while (k--) {
                        int x; cin >> x; g[i].pb(x);
                }
        }
        for (auto &i : g) sort(all(i));
        int ans = 0;
        for (int i = 0; i < n; ++i) {
                if (sz(g[i]) + 1 <= ans) continue;
                for (int msk = 0; msk < pw(sz(g[i])); ++msk) {
                        if (__builtin_popcount(msk) + 1 <= ans) continue;
                        bool ok = 1;
                        vector <int> ar; ar.pb(i);
                        for (int j = 0; j < sz(g[i]); ++j) {
                                if (!(msk >> j & 1)) continue;
                                ar.pb(g[i][j]);
                        }
                        for (int i = 0; i < sz(ar); ++i) {
                                for (int j = i + 1; j < sz(ar); ++j) {
                                        if (!binary_search(all(g[ar[i]]), ar[j])) {
                                                ok = 0; break;
                                        }
                                }
                        }
                        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;
}

Compilation message

politicaldevelopment.cpp: In function 'void solve()':
politicaldevelopment.cpp:31:19: warning: unused variable 'N' [-Wunused-variable]
   31 |         const int N = 50005;
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 13 ms 604 KB Output is correct
4 Correct 7 ms 596 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 9 ms 596 KB Output is correct
7 Correct 9 ms 628 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 13 ms 604 KB Output is correct
4 Correct 7 ms 596 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 9 ms 596 KB Output is correct
7 Correct 9 ms 628 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 8 ms 596 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 10 ms 596 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 10 ms 596 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 8 ms 596 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 6 ms 596 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 8 ms 596 KB Output is correct
26 Correct 6 ms 480 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 4 ms 596 KB Output is correct
31 Correct 7 ms 596 KB Output is correct
32 Correct 5 ms 596 KB Output is correct
33 Correct 6 ms 596 KB Output is correct
34 Correct 6 ms 600 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 4 ms 464 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Execution timed out 3041 ms 340 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3061 ms 5332 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 13 ms 604 KB Output is correct
4 Correct 7 ms 596 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 9 ms 596 KB Output is correct
7 Correct 9 ms 628 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 8 ms 596 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 10 ms 596 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 10 ms 596 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 8 ms 596 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 6 ms 596 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 8 ms 596 KB Output is correct
26 Correct 6 ms 480 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 4 ms 596 KB Output is correct
31 Correct 7 ms 596 KB Output is correct
32 Correct 5 ms 596 KB Output is correct
33 Correct 6 ms 596 KB Output is correct
34 Correct 6 ms 600 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 4 ms 464 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Execution timed out 3041 ms 340 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 13 ms 604 KB Output is correct
4 Correct 7 ms 596 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 9 ms 596 KB Output is correct
7 Correct 9 ms 628 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 596 KB Output is correct
12 Correct 8 ms 596 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 10 ms 596 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 10 ms 596 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 8 ms 596 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 6 ms 596 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 8 ms 596 KB Output is correct
26 Correct 6 ms 480 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 4 ms 596 KB Output is correct
31 Correct 7 ms 596 KB Output is correct
32 Correct 5 ms 596 KB Output is correct
33 Correct 6 ms 596 KB Output is correct
34 Correct 6 ms 600 KB Output is correct
35 Correct 3 ms 340 KB Output is correct
36 Correct 4 ms 464 KB Output is correct
37 Correct 3 ms 340 KB Output is correct
38 Execution timed out 3041 ms 340 KB Time limit exceeded
39 Halted 0 ms 0 KB -