답안 #682696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682696 2023-01-16T19:44:12 Z Lobo Political Development (BOI17_politicaldevelopment) C++17
39 / 100
345 ms 38256 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());

        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();
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 7 ms 4820 KB Output is correct
5 Correct 7 ms 4820 KB Output is correct
6 Correct 9 ms 4956 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 7 ms 4820 KB Output is correct
5 Correct 7 ms 4820 KB Output is correct
6 Correct 9 ms 4956 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 4820 KB Output is correct
12 Correct 6 ms 4820 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 7 ms 4888 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 7 ms 4948 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4952 KB Output is correct
19 Correct 4 ms 4112 KB Output is correct
20 Correct 5 ms 4628 KB Output is correct
21 Correct 6 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 5040 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 7 ms 4948 KB Output is correct
26 Correct 7 ms 4904 KB Output is correct
27 Correct 6 ms 4820 KB Output is correct
28 Correct 7 ms 4880 KB Output is correct
29 Correct 6 ms 4888 KB Output is correct
30 Correct 10 ms 5008 KB Output is correct
31 Correct 8 ms 5076 KB Output is correct
32 Correct 8 ms 5108 KB Output is correct
33 Correct 8 ms 5076 KB Output is correct
34 Correct 8 ms 5012 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4364 KB Output is correct
37 Correct 5 ms 4368 KB Output is correct
38 Correct 4 ms 4180 KB Output is correct
39 Correct 4 ms 4180 KB Output is correct
40 Correct 13 ms 5460 KB Output is correct
41 Correct 5 ms 4240 KB Output is correct
42 Correct 12 ms 5516 KB Output is correct
43 Correct 12 ms 5460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4104 KB Output is correct
2 Correct 3 ms 3852 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 3 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 3844 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 3 ms 3796 KB Output is correct
11 Correct 319 ms 38256 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 318 ms 38152 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 323 ms 38080 KB Output is correct
16 Correct 326 ms 38172 KB Output is correct
17 Correct 302 ms 38168 KB Output is correct
18 Correct 345 ms 38116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 7 ms 4820 KB Output is correct
5 Correct 7 ms 4820 KB Output is correct
6 Correct 9 ms 4956 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 4820 KB Output is correct
12 Correct 6 ms 4820 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 7 ms 4888 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 7 ms 4948 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4952 KB Output is correct
19 Correct 4 ms 4112 KB Output is correct
20 Correct 5 ms 4628 KB Output is correct
21 Correct 6 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 5040 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 7 ms 4948 KB Output is correct
26 Correct 7 ms 4904 KB Output is correct
27 Correct 6 ms 4820 KB Output is correct
28 Correct 7 ms 4880 KB Output is correct
29 Correct 6 ms 4888 KB Output is correct
30 Correct 10 ms 5008 KB Output is correct
31 Correct 8 ms 5076 KB Output is correct
32 Correct 8 ms 5108 KB Output is correct
33 Correct 8 ms 5076 KB Output is correct
34 Correct 8 ms 5012 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4364 KB Output is correct
37 Correct 5 ms 4368 KB Output is correct
38 Correct 4 ms 4180 KB Output is correct
39 Correct 4 ms 4180 KB Output is correct
40 Correct 13 ms 5460 KB Output is correct
41 Correct 5 ms 4240 KB Output is correct
42 Correct 12 ms 5516 KB Output is correct
43 Correct 12 ms 5460 KB Output is correct
44 Correct 16 ms 6612 KB Output is correct
45 Correct 2 ms 3796 KB Output is correct
46 Correct 11 ms 5524 KB Output is correct
47 Correct 21 ms 6744 KB Output is correct
48 Correct 11 ms 5508 KB Output is correct
49 Correct 22 ms 6740 KB Output is correct
50 Correct 27 ms 6788 KB Output is correct
51 Correct 47 ms 9280 KB Output is correct
52 Correct 6 ms 4884 KB Output is correct
53 Correct 42 ms 9920 KB Output is correct
54 Correct 54 ms 9828 KB Output is correct
55 Correct 6 ms 4948 KB Output is correct
56 Correct 7 ms 4928 KB Output is correct
57 Correct 3 ms 4168 KB Output is correct
58 Correct 41 ms 9880 KB Output is correct
59 Correct 9 ms 5460 KB Output is correct
60 Correct 9 ms 4884 KB Output is correct
61 Correct 9 ms 5472 KB Output is correct
62 Correct 8 ms 5396 KB Output is correct
63 Correct 17 ms 6672 KB Output is correct
64 Correct 16 ms 6416 KB Output is correct
65 Correct 10 ms 5368 KB Output is correct
66 Correct 10 ms 5396 KB Output is correct
67 Correct 25 ms 7252 KB Output is correct
68 Correct 15 ms 6356 KB Output is correct
69 Correct 10 ms 5264 KB Output is correct
70 Correct 25 ms 6484 KB Output is correct
71 Correct 26 ms 7220 KB Output is correct
72 Correct 26 ms 7056 KB Output is correct
73 Correct 6 ms 4880 KB Output is correct
74 Correct 19 ms 6484 KB Output is correct
75 Correct 24 ms 7128 KB Output is correct
76 Correct 15 ms 5860 KB Output is correct
77 Correct 32 ms 7828 KB Output is correct
78 Correct 7 ms 4884 KB Output is correct
79 Correct 20 ms 5844 KB Output is correct
80 Correct 14 ms 5844 KB Output is correct
81 Correct 31 ms 7816 KB Output is correct
82 Correct 4 ms 4240 KB Output is correct
83 Correct 18 ms 5888 KB Output is correct
84 Correct 25 ms 7124 KB Output is correct
85 Correct 4 ms 4180 KB Output is correct
86 Incorrect 24 ms 7124 KB Output isn't correct
87 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 7 ms 4820 KB Output is correct
5 Correct 7 ms 4820 KB Output is correct
6 Correct 9 ms 4956 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 3796 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 4820 KB Output is correct
12 Correct 6 ms 4820 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 7 ms 4888 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 7 ms 4948 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 7 ms 4952 KB Output is correct
19 Correct 4 ms 4112 KB Output is correct
20 Correct 5 ms 4628 KB Output is correct
21 Correct 6 ms 4564 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 8 ms 5040 KB Output is correct
24 Correct 3 ms 4180 KB Output is correct
25 Correct 7 ms 4948 KB Output is correct
26 Correct 7 ms 4904 KB Output is correct
27 Correct 6 ms 4820 KB Output is correct
28 Correct 7 ms 4880 KB Output is correct
29 Correct 6 ms 4888 KB Output is correct
30 Correct 10 ms 5008 KB Output is correct
31 Correct 8 ms 5076 KB Output is correct
32 Correct 8 ms 5108 KB Output is correct
33 Correct 8 ms 5076 KB Output is correct
34 Correct 8 ms 5012 KB Output is correct
35 Correct 5 ms 4436 KB Output is correct
36 Correct 5 ms 4364 KB Output is correct
37 Correct 5 ms 4368 KB Output is correct
38 Correct 4 ms 4180 KB Output is correct
39 Correct 4 ms 4180 KB Output is correct
40 Correct 13 ms 5460 KB Output is correct
41 Correct 5 ms 4240 KB Output is correct
42 Correct 12 ms 5516 KB Output is correct
43 Correct 12 ms 5460 KB Output is correct
44 Correct 2 ms 3796 KB Output is correct
45 Correct 215 ms 27124 KB Output is correct
46 Correct 83 ms 17472 KB Output is correct
47 Correct 209 ms 27140 KB Output is correct
48 Correct 211 ms 27016 KB Output is correct
49 Correct 58 ms 14656 KB Output is correct
50 Correct 199 ms 32436 KB Output is correct
51 Correct 197 ms 27092 KB Output is correct
52 Correct 52 ms 14600 KB Output is correct
53 Correct 59 ms 14636 KB Output is correct
54 Correct 14 ms 7380 KB Output is correct
55 Correct 204 ms 32424 KB Output is correct
56 Correct 36 ms 11544 KB Output is correct
57 Correct 50 ms 14636 KB Output is correct
58 Correct 69 ms 17668 KB Output is correct
59 Correct 36 ms 11640 KB Output is correct
60 Correct 35 ms 11552 KB Output is correct
61 Correct 84 ms 17588 KB Output is correct
62 Correct 51 ms 14208 KB Output is correct
63 Correct 118 ms 19140 KB Output is correct
64 Correct 35 ms 11648 KB Output is correct
65 Correct 139 ms 22288 KB Output is correct
66 Correct 51 ms 14156 KB Output is correct
67 Correct 105 ms 19148 KB Output is correct
68 Correct 130 ms 21536 KB Output is correct
69 Correct 142 ms 22348 KB Output is correct
70 Correct 62 ms 14156 KB Output is correct
71 Correct 138 ms 21472 KB Output is correct
72 Correct 108 ms 18648 KB Output is correct
73 Correct 172 ms 24316 KB Output is correct
74 Correct 65 ms 14284 KB Output is correct
75 Correct 56 ms 12064 KB Output is correct
76 Correct 97 ms 18632 KB Output is correct
77 Correct 158 ms 24228 KB Output is correct
78 Correct 78 ms 13968 KB Output is correct
79 Correct 53 ms 12104 KB Output is correct
80 Correct 24 ms 7892 KB Output is correct
81 Correct 73 ms 14056 KB Output is correct
82 Correct 122 ms 20316 KB Output is correct
83 Correct 32 ms 7884 KB Output is correct
84 Incorrect 122 ms 20280 KB Output isn't correct
85 Halted 0 ms 0 KB -