#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair<ll, int> pp;
#define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define ss second
#define ff first
void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
void IOS(){
cin.tie(0) -> sync_with_stdio(0);
// #ifndef ONLINE_JUDGE
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
// #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 998244353, maxn = 5e4 + 5, maxk = 11, lg = 35, inf = ll(1e18) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}
vector<int> adj[maxn];
vector<int> mask[maxk][maxk];
int cnt[maxn];
bool chk(int x, vector<int> cand){
int n = sz(cand);
vector<int> adj(n);
rep(i,0,n) {
adj[i] ^= 1<<i;
rep(j,0,i){
auto it = lower_bound(all(::adj[cand[i]]), cand[j]);
if(it != end(::adj[i]) && *it == cand[j]) adj[i] ^= 1<<j, adj[j] ^= 1<<i;
}
}
for(int m: mask[n][x]){
bool ok = true;
rep(i,0,n) if((m>>i&1) && (adj[i]&m) != m) {
ok = false;
break;
}
if(ok) return true;
}
return false;
}
int main(){ IOS();
int n, k, ans = 1; cin >> n >> k;
set<pp> s;
rep(i,0,n){
int d; cin >> d;
s.insert({cnt[i] = d, i});
adj[i].resize(d);
rep(j,0,d) cin >> adj[i][j];
sort(all(adj[i]));
}
rep(i,0,k+1){
rep(j,0,1<<i) mask[i][__builtin_popcount(j)].pb(j);
}
while(sz(s)){
int r = s.begin()->ss;
s.erase(begin(s)), cnt[r] = -1;
vector<int> ad{r};
for(int c: adj[r]) if(cnt[c] > 0){
ad.pb(c);
s.erase(pp(cnt[c], c));
s.insert({--cnt[c], c});
}
// er(r);
// for(int c: ad) cerr << c << ' '; cerr << endl;
while(ans < sz(ad) && chk(ans+1, ad)) ans++;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1504 KB |
Output is correct |
3 |
Correct |
5 ms |
2032 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2072 KB |
Output is correct |
6 |
Correct |
5 ms |
2032 KB |
Output is correct |
7 |
Correct |
5 ms |
2004 KB |
Output is correct |
8 |
Correct |
3 ms |
1772 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1504 KB |
Output is correct |
3 |
Correct |
5 ms |
2032 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2072 KB |
Output is correct |
6 |
Correct |
5 ms |
2032 KB |
Output is correct |
7 |
Correct |
5 ms |
2004 KB |
Output is correct |
8 |
Correct |
3 ms |
1772 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1768 KB |
Output is correct |
11 |
Correct |
4 ms |
2004 KB |
Output is correct |
12 |
Correct |
4 ms |
2004 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
2004 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
5 ms |
2004 KB |
Output is correct |
17 |
Correct |
1 ms |
1512 KB |
Output is correct |
18 |
Correct |
4 ms |
2004 KB |
Output is correct |
19 |
Correct |
3 ms |
1768 KB |
Output is correct |
20 |
Correct |
3 ms |
2032 KB |
Output is correct |
21 |
Correct |
3 ms |
2032 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
6 ms |
2032 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
7 ms |
2068 KB |
Output is correct |
26 |
Correct |
6 ms |
2004 KB |
Output is correct |
27 |
Correct |
5 ms |
2004 KB |
Output is correct |
28 |
Correct |
5 ms |
2004 KB |
Output is correct |
29 |
Correct |
4 ms |
2028 KB |
Output is correct |
30 |
Correct |
5 ms |
2004 KB |
Output is correct |
31 |
Correct |
6 ms |
2056 KB |
Output is correct |
32 |
Correct |
5 ms |
2032 KB |
Output is correct |
33 |
Correct |
6 ms |
2024 KB |
Output is correct |
34 |
Correct |
6 ms |
2004 KB |
Output is correct |
35 |
Correct |
3 ms |
1748 KB |
Output is correct |
36 |
Correct |
3 ms |
1748 KB |
Output is correct |
37 |
Correct |
3 ms |
1748 KB |
Output is correct |
38 |
Correct |
3 ms |
1652 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
9 ms |
2004 KB |
Output is correct |
41 |
Correct |
4 ms |
1748 KB |
Output is correct |
42 |
Correct |
8 ms |
2112 KB |
Output is correct |
43 |
Correct |
8 ms |
2112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1504 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1492 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1492 KB |
Output is correct |
11 |
Correct |
206 ms |
7304 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
212 ms |
7236 KB |
Output is correct |
14 |
Correct |
1 ms |
1492 KB |
Output is correct |
15 |
Correct |
200 ms |
7212 KB |
Output is correct |
16 |
Correct |
225 ms |
7304 KB |
Output is correct |
17 |
Correct |
205 ms |
7220 KB |
Output is correct |
18 |
Correct |
213 ms |
7288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1504 KB |
Output is correct |
3 |
Correct |
5 ms |
2032 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2072 KB |
Output is correct |
6 |
Correct |
5 ms |
2032 KB |
Output is correct |
7 |
Correct |
5 ms |
2004 KB |
Output is correct |
8 |
Correct |
3 ms |
1772 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1768 KB |
Output is correct |
11 |
Correct |
4 ms |
2004 KB |
Output is correct |
12 |
Correct |
4 ms |
2004 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
2004 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
5 ms |
2004 KB |
Output is correct |
17 |
Correct |
1 ms |
1512 KB |
Output is correct |
18 |
Correct |
4 ms |
2004 KB |
Output is correct |
19 |
Correct |
3 ms |
1768 KB |
Output is correct |
20 |
Correct |
3 ms |
2032 KB |
Output is correct |
21 |
Correct |
3 ms |
2032 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
6 ms |
2032 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
7 ms |
2068 KB |
Output is correct |
26 |
Correct |
6 ms |
2004 KB |
Output is correct |
27 |
Correct |
5 ms |
2004 KB |
Output is correct |
28 |
Correct |
5 ms |
2004 KB |
Output is correct |
29 |
Correct |
4 ms |
2028 KB |
Output is correct |
30 |
Correct |
5 ms |
2004 KB |
Output is correct |
31 |
Correct |
6 ms |
2056 KB |
Output is correct |
32 |
Correct |
5 ms |
2032 KB |
Output is correct |
33 |
Correct |
6 ms |
2024 KB |
Output is correct |
34 |
Correct |
6 ms |
2004 KB |
Output is correct |
35 |
Correct |
3 ms |
1748 KB |
Output is correct |
36 |
Correct |
3 ms |
1748 KB |
Output is correct |
37 |
Correct |
3 ms |
1748 KB |
Output is correct |
38 |
Correct |
3 ms |
1652 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
9 ms |
2004 KB |
Output is correct |
41 |
Correct |
4 ms |
1748 KB |
Output is correct |
42 |
Correct |
8 ms |
2112 KB |
Output is correct |
43 |
Correct |
8 ms |
2112 KB |
Output is correct |
44 |
Correct |
12 ms |
2156 KB |
Output is correct |
45 |
Correct |
1 ms |
1516 KB |
Output is correct |
46 |
Correct |
10 ms |
2112 KB |
Output is correct |
47 |
Correct |
17 ms |
2132 KB |
Output is correct |
48 |
Correct |
8 ms |
2004 KB |
Output is correct |
49 |
Correct |
15 ms |
2128 KB |
Output is correct |
50 |
Correct |
15 ms |
2124 KB |
Output is correct |
51 |
Correct |
33 ms |
2348 KB |
Output is correct |
52 |
Correct |
4 ms |
2004 KB |
Output is correct |
53 |
Correct |
25 ms |
2364 KB |
Output is correct |
54 |
Correct |
38 ms |
2376 KB |
Output is correct |
55 |
Correct |
6 ms |
2004 KB |
Output is correct |
56 |
Correct |
5 ms |
2028 KB |
Output is correct |
57 |
Correct |
2 ms |
1748 KB |
Output is correct |
58 |
Correct |
34 ms |
2260 KB |
Output is correct |
59 |
Correct |
6 ms |
2004 KB |
Output is correct |
60 |
Correct |
5 ms |
2004 KB |
Output is correct |
61 |
Correct |
6 ms |
2004 KB |
Output is correct |
62 |
Correct |
6 ms |
2004 KB |
Output is correct |
63 |
Correct |
10 ms |
2208 KB |
Output is correct |
64 |
Correct |
9 ms |
2132 KB |
Output is correct |
65 |
Correct |
9 ms |
2004 KB |
Output is correct |
66 |
Correct |
6 ms |
2004 KB |
Output is correct |
67 |
Correct |
18 ms |
2112 KB |
Output is correct |
68 |
Correct |
9 ms |
2156 KB |
Output is correct |
69 |
Correct |
8 ms |
2004 KB |
Output is correct |
70 |
Correct |
13 ms |
2108 KB |
Output is correct |
71 |
Correct |
17 ms |
2140 KB |
Output is correct |
72 |
Correct |
17 ms |
2164 KB |
Output is correct |
73 |
Correct |
5 ms |
2004 KB |
Output is correct |
74 |
Correct |
16 ms |
2192 KB |
Output is correct |
75 |
Correct |
16 ms |
2232 KB |
Output is correct |
76 |
Correct |
11 ms |
2092 KB |
Output is correct |
77 |
Correct |
21 ms |
2264 KB |
Output is correct |
78 |
Correct |
5 ms |
2028 KB |
Output is correct |
79 |
Correct |
10 ms |
1960 KB |
Output is correct |
80 |
Correct |
9 ms |
2132 KB |
Output is correct |
81 |
Correct |
22 ms |
2260 KB |
Output is correct |
82 |
Correct |
3 ms |
1620 KB |
Output is correct |
83 |
Correct |
10 ms |
1876 KB |
Output is correct |
84 |
Correct |
15 ms |
2132 KB |
Output is correct |
85 |
Correct |
3 ms |
1620 KB |
Output is correct |
86 |
Correct |
15 ms |
2168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1504 KB |
Output is correct |
3 |
Correct |
5 ms |
2032 KB |
Output is correct |
4 |
Correct |
4 ms |
2004 KB |
Output is correct |
5 |
Correct |
5 ms |
2072 KB |
Output is correct |
6 |
Correct |
5 ms |
2032 KB |
Output is correct |
7 |
Correct |
5 ms |
2004 KB |
Output is correct |
8 |
Correct |
3 ms |
1772 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1768 KB |
Output is correct |
11 |
Correct |
4 ms |
2004 KB |
Output is correct |
12 |
Correct |
4 ms |
2004 KB |
Output is correct |
13 |
Correct |
1 ms |
1492 KB |
Output is correct |
14 |
Correct |
4 ms |
2004 KB |
Output is correct |
15 |
Correct |
1 ms |
1492 KB |
Output is correct |
16 |
Correct |
5 ms |
2004 KB |
Output is correct |
17 |
Correct |
1 ms |
1512 KB |
Output is correct |
18 |
Correct |
4 ms |
2004 KB |
Output is correct |
19 |
Correct |
3 ms |
1768 KB |
Output is correct |
20 |
Correct |
3 ms |
2032 KB |
Output is correct |
21 |
Correct |
3 ms |
2032 KB |
Output is correct |
22 |
Correct |
3 ms |
1748 KB |
Output is correct |
23 |
Correct |
6 ms |
2032 KB |
Output is correct |
24 |
Correct |
2 ms |
1748 KB |
Output is correct |
25 |
Correct |
7 ms |
2068 KB |
Output is correct |
26 |
Correct |
6 ms |
2004 KB |
Output is correct |
27 |
Correct |
5 ms |
2004 KB |
Output is correct |
28 |
Correct |
5 ms |
2004 KB |
Output is correct |
29 |
Correct |
4 ms |
2028 KB |
Output is correct |
30 |
Correct |
5 ms |
2004 KB |
Output is correct |
31 |
Correct |
6 ms |
2056 KB |
Output is correct |
32 |
Correct |
5 ms |
2032 KB |
Output is correct |
33 |
Correct |
6 ms |
2024 KB |
Output is correct |
34 |
Correct |
6 ms |
2004 KB |
Output is correct |
35 |
Correct |
3 ms |
1748 KB |
Output is correct |
36 |
Correct |
3 ms |
1748 KB |
Output is correct |
37 |
Correct |
3 ms |
1748 KB |
Output is correct |
38 |
Correct |
3 ms |
1652 KB |
Output is correct |
39 |
Correct |
3 ms |
1620 KB |
Output is correct |
40 |
Correct |
9 ms |
2004 KB |
Output is correct |
41 |
Correct |
4 ms |
1748 KB |
Output is correct |
42 |
Correct |
8 ms |
2112 KB |
Output is correct |
43 |
Correct |
8 ms |
2112 KB |
Output is correct |
44 |
Correct |
1 ms |
1492 KB |
Output is correct |
45 |
Correct |
151 ms |
6864 KB |
Output is correct |
46 |
Correct |
56 ms |
6600 KB |
Output is correct |
47 |
Correct |
145 ms |
6968 KB |
Output is correct |
48 |
Correct |
150 ms |
6864 KB |
Output is correct |
49 |
Correct |
45 ms |
6608 KB |
Output is correct |
50 |
Correct |
144 ms |
7304 KB |
Output is correct |
51 |
Correct |
138 ms |
6824 KB |
Output is correct |
52 |
Correct |
44 ms |
6608 KB |
Output is correct |
53 |
Correct |
42 ms |
6588 KB |
Output is correct |
54 |
Correct |
14 ms |
4924 KB |
Output is correct |
55 |
Correct |
145 ms |
7244 KB |
Output is correct |
56 |
Correct |
33 ms |
6512 KB |
Output is correct |
57 |
Correct |
47 ms |
6700 KB |
Output is correct |
58 |
Correct |
51 ms |
6492 KB |
Output is correct |
59 |
Correct |
36 ms |
6540 KB |
Output is correct |
60 |
Correct |
32 ms |
6484 KB |
Output is correct |
61 |
Correct |
52 ms |
6520 KB |
Output is correct |
62 |
Correct |
46 ms |
6480 KB |
Output is correct |
63 |
Correct |
98 ms |
6452 KB |
Output is correct |
64 |
Correct |
34 ms |
6460 KB |
Output is correct |
65 |
Correct |
110 ms |
6656 KB |
Output is correct |
66 |
Correct |
46 ms |
6516 KB |
Output is correct |
67 |
Correct |
83 ms |
6476 KB |
Output is correct |
68 |
Correct |
95 ms |
6612 KB |
Output is correct |
69 |
Correct |
98 ms |
6536 KB |
Output is correct |
70 |
Correct |
46 ms |
6500 KB |
Output is correct |
71 |
Correct |
105 ms |
6608 KB |
Output is correct |
72 |
Correct |
68 ms |
6644 KB |
Output is correct |
73 |
Correct |
115 ms |
6556 KB |
Output is correct |
74 |
Correct |
46 ms |
6500 KB |
Output is correct |
75 |
Correct |
41 ms |
4072 KB |
Output is correct |
76 |
Correct |
81 ms |
6644 KB |
Output is correct |
77 |
Correct |
123 ms |
6676 KB |
Output is correct |
78 |
Correct |
53 ms |
4116 KB |
Output is correct |
79 |
Correct |
45 ms |
4076 KB |
Output is correct |
80 |
Correct |
20 ms |
2900 KB |
Output is correct |
81 |
Correct |
53 ms |
4128 KB |
Output is correct |
82 |
Correct |
114 ms |
6400 KB |
Output is correct |
83 |
Correct |
19 ms |
2900 KB |
Output is correct |
84 |
Correct |
117 ms |
6504 KB |
Output is correct |