Submission #682697

# Submission time Handle Problem Language Result Execution time Memory
682697 2023-01-16T19:47:01 Z Lobo Political Development (BOI17_politicaldevelopment) C++17
39 / 100
329 ms 37096 KB
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 5e4+10;

int n, k, gr[maxn];
vector<int> g[maxn];
set<int> stg[maxn];

void solve() {
    cin >> n >> k;
    int ans = 1;
    for(int i = 0; i < n; i++) {
        int d; cin >> d; 
        gr[i] = d;
        if(d != 0) ans = 2;
        while(d--) {
            int x; cin >> x;
            stg[i].insert(x);
            g[i].pb(x);
        }
    }

    set<pair<int,int>> st;
    for(int i = 0; i < n; i++) {
        st.insert(mp(gr[i],i));
    }

    while(st.size()) {
        int u = st.begin()->sc;
        st.erase(st.begin());
        if(stg[u].size() > k) {
            ans = k;
            break;
        }

        bool ok = true;
        for(auto v1 : stg[u]) {
            for(auto v2 : stg[u]) {
                if(v1 != v2 && stg[v1].count(v2) == 0) ok = false;
            }
        }

        if(ok) ans = max(ans, gr[u]+1);

        for(auto v : stg[u]) {
            stg[v].erase(u);
            st.erase(mp(gr[v],v));
            --gr[v];
            st.insert(mp(gr[v],v));
        }
    }
    
    cout << ans << endl;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}

Compilation message

politicaldevelopment.cpp: In function 'void solve()':
politicaldevelopment.cpp:41:26: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   41 |         if(stg[u].size() > k) {
      |            ~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 7 ms 4820 KB Output is correct
4 Correct 6 ms 4860 KB Output is correct
5 Correct 6 ms 4772 KB Output is correct
6 Correct 6 ms 4820 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 7 ms 4820 KB Output is correct
4 Correct 6 ms 4860 KB Output is correct
5 Correct 6 ms 4772 KB Output is correct
6 Correct 6 ms 4820 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 7 ms 4820 KB Output is correct
12 Correct 7 ms 4820 KB Output is correct
13 Correct 2 ms 3844 KB Output is correct
14 Correct 6 ms 4820 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 6 ms 4820 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4820 KB Output is correct
19 Correct 3 ms 4180 KB Output is correct
20 Correct 5 ms 4564 KB Output is correct
21 Correct 5 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 4948 KB Output is correct
24 Correct 3 ms 4116 KB Output is correct
25 Correct 8 ms 4948 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4820 KB Output is correct
28 Correct 8 ms 4896 KB Output is correct
29 Correct 6 ms 4820 KB Output is correct
30 Correct 7 ms 4948 KB Output is correct
31 Correct 7 ms 4892 KB Output is correct
32 Correct 8 ms 4948 KB Output is correct
33 Correct 8 ms 4908 KB Output is correct
34 Correct 7 ms 4948 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4436 KB Output is correct
37 Correct 5 ms 4436 KB Output is correct
38 Correct 6 ms 4180 KB Output is correct
39 Correct 6 ms 4180 KB Output is correct
40 Correct 12 ms 5332 KB Output is correct
41 Correct 5 ms 4180 KB Output is correct
42 Correct 11 ms 5332 KB Output is correct
43 Correct 10 ms 5416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 2 ms 3796 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
9 Correct 3 ms 3788 KB Output is correct
10 Correct 3 ms 3796 KB Output is correct
11 Correct 329 ms 37060 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 319 ms 37060 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 306 ms 37068 KB Output is correct
16 Correct 322 ms 37028 KB Output is correct
17 Correct 312 ms 36944 KB Output is correct
18 Correct 298 ms 37096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 7 ms 4820 KB Output is correct
4 Correct 6 ms 4860 KB Output is correct
5 Correct 6 ms 4772 KB Output is correct
6 Correct 6 ms 4820 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 7 ms 4820 KB Output is correct
12 Correct 7 ms 4820 KB Output is correct
13 Correct 2 ms 3844 KB Output is correct
14 Correct 6 ms 4820 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 6 ms 4820 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4820 KB Output is correct
19 Correct 3 ms 4180 KB Output is correct
20 Correct 5 ms 4564 KB Output is correct
21 Correct 5 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 4948 KB Output is correct
24 Correct 3 ms 4116 KB Output is correct
25 Correct 8 ms 4948 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4820 KB Output is correct
28 Correct 8 ms 4896 KB Output is correct
29 Correct 6 ms 4820 KB Output is correct
30 Correct 7 ms 4948 KB Output is correct
31 Correct 7 ms 4892 KB Output is correct
32 Correct 8 ms 4948 KB Output is correct
33 Correct 8 ms 4908 KB Output is correct
34 Correct 7 ms 4948 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4436 KB Output is correct
37 Correct 5 ms 4436 KB Output is correct
38 Correct 6 ms 4180 KB Output is correct
39 Correct 6 ms 4180 KB Output is correct
40 Correct 12 ms 5332 KB Output is correct
41 Correct 5 ms 4180 KB Output is correct
42 Correct 11 ms 5332 KB Output is correct
43 Correct 10 ms 5416 KB Output is correct
44 Correct 20 ms 6360 KB Output is correct
45 Correct 2 ms 3748 KB Output is correct
46 Correct 14 ms 5460 KB Output is correct
47 Correct 27 ms 6484 KB Output is correct
48 Correct 11 ms 5332 KB Output is correct
49 Correct 21 ms 6728 KB Output is correct
50 Correct 21 ms 6612 KB Output is correct
51 Correct 47 ms 9172 KB Output is correct
52 Correct 8 ms 4820 KB Output is correct
53 Correct 44 ms 9716 KB Output is correct
54 Correct 62 ms 9928 KB Output is correct
55 Correct 7 ms 4956 KB Output is correct
56 Correct 6 ms 4884 KB Output is correct
57 Correct 3 ms 4112 KB Output is correct
58 Correct 45 ms 9920 KB Output is correct
59 Correct 9 ms 5460 KB Output is correct
60 Correct 7 ms 4904 KB Output is correct
61 Correct 9 ms 5460 KB Output is correct
62 Correct 9 ms 5480 KB Output is correct
63 Correct 16 ms 6612 KB Output is correct
64 Correct 16 ms 6352 KB Output is correct
65 Correct 12 ms 5320 KB Output is correct
66 Correct 9 ms 5452 KB Output is correct
67 Correct 25 ms 7060 KB Output is correct
68 Correct 15 ms 6416 KB Output is correct
69 Correct 10 ms 5268 KB Output is correct
70 Correct 19 ms 6520 KB Output is correct
71 Correct 26 ms 7184 KB Output is correct
72 Correct 24 ms 7124 KB Output is correct
73 Correct 7 ms 4884 KB Output is correct
74 Correct 20 ms 6536 KB Output is correct
75 Correct 25 ms 7124 KB Output is correct
76 Correct 16 ms 5944 KB Output is correct
77 Correct 39 ms 7920 KB Output is correct
78 Correct 8 ms 4820 KB Output is correct
79 Correct 19 ms 5860 KB Output is correct
80 Correct 15 ms 5916 KB Output is correct
81 Correct 31 ms 7768 KB Output is correct
82 Correct 5 ms 4180 KB Output is correct
83 Correct 16 ms 5868 KB Output is correct
84 Correct 24 ms 7120 KB Output is correct
85 Correct 4 ms 4180 KB Output is correct
86 Incorrect 23 ms 7124 KB Output isn't correct
87 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 7 ms 4820 KB Output is correct
4 Correct 6 ms 4860 KB Output is correct
5 Correct 6 ms 4772 KB Output is correct
6 Correct 6 ms 4820 KB Output is correct
7 Correct 6 ms 4812 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 7 ms 4820 KB Output is correct
12 Correct 7 ms 4820 KB Output is correct
13 Correct 2 ms 3844 KB Output is correct
14 Correct 6 ms 4820 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 6 ms 4820 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4820 KB Output is correct
19 Correct 3 ms 4180 KB Output is correct
20 Correct 5 ms 4564 KB Output is correct
21 Correct 5 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 4948 KB Output is correct
24 Correct 3 ms 4116 KB Output is correct
25 Correct 8 ms 4948 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4820 KB Output is correct
28 Correct 8 ms 4896 KB Output is correct
29 Correct 6 ms 4820 KB Output is correct
30 Correct 7 ms 4948 KB Output is correct
31 Correct 7 ms 4892 KB Output is correct
32 Correct 8 ms 4948 KB Output is correct
33 Correct 8 ms 4908 KB Output is correct
34 Correct 7 ms 4948 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4436 KB Output is correct
37 Correct 5 ms 4436 KB Output is correct
38 Correct 6 ms 4180 KB Output is correct
39 Correct 6 ms 4180 KB Output is correct
40 Correct 12 ms 5332 KB Output is correct
41 Correct 5 ms 4180 KB Output is correct
42 Correct 11 ms 5332 KB Output is correct
43 Correct 10 ms 5416 KB Output is correct
44 Correct 2 ms 3796 KB Output is correct
45 Correct 211 ms 25420 KB Output is correct
46 Correct 83 ms 17408 KB Output is correct
47 Correct 211 ms 26872 KB Output is correct
48 Correct 211 ms 26876 KB Output is correct
49 Correct 67 ms 14612 KB Output is correct
50 Correct 198 ms 31604 KB Output is correct
51 Correct 202 ms 26936 KB Output is correct
52 Correct 65 ms 14668 KB Output is correct
53 Correct 59 ms 14652 KB Output is correct
54 Correct 14 ms 7380 KB Output is correct
55 Correct 200 ms 31696 KB Output is correct
56 Correct 37 ms 11616 KB Output is correct
57 Correct 54 ms 14668 KB Output is correct
58 Correct 70 ms 17580 KB Output is correct
59 Correct 37 ms 11604 KB Output is correct
60 Correct 41 ms 11644 KB Output is correct
61 Correct 81 ms 17660 KB Output is correct
62 Correct 54 ms 14232 KB Output is correct
63 Correct 119 ms 19188 KB Output is correct
64 Correct 39 ms 11636 KB Output is correct
65 Correct 145 ms 22352 KB Output is correct
66 Correct 51 ms 14268 KB Output is correct
67 Correct 116 ms 19072 KB Output is correct
68 Correct 142 ms 21440 KB Output is correct
69 Correct 141 ms 22332 KB Output is correct
70 Correct 60 ms 14252 KB Output is correct
71 Correct 138 ms 21516 KB Output is correct
72 Correct 115 ms 18568 KB Output is correct
73 Correct 164 ms 24288 KB Output is correct
74 Correct 61 ms 14240 KB Output is correct
75 Correct 58 ms 12112 KB Output is correct
76 Correct 104 ms 18568 KB Output is correct
77 Correct 157 ms 24240 KB Output is correct
78 Correct 71 ms 14048 KB Output is correct
79 Correct 51 ms 12088 KB Output is correct
80 Correct 25 ms 7788 KB Output is correct
81 Correct 69 ms 13552 KB Output is correct
82 Correct 122 ms 19820 KB Output is correct
83 Correct 24 ms 7600 KB Output is correct
84 Incorrect 126 ms 20300 KB Output isn't correct
85 Halted 0 ms 0 KB -