#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int> tii;
typedef tuple<ll,ll,ll> tll;
typedef vector<vector<ll>> mat;
const ll mod=1e9+7;
const int N=1e5+5;
int n,ans,deg[N],k;
bool ok[N];
set<pii> st,degs;
set<int> g[N];
vector<int> v;
int sz,okmask[15];
void backtrack(int c,int cur,int mask){
if(c==sz){
for(int i=0;i<sz;i++) if(mask&(1<<i)){
if((okmask[i]&mask)!=mask) return;
}
ans=max(ans,cur+1);
return;
}
backtrack(c+1,cur+1,mask|(1<<c));
backtrack(c+1,cur,mask);
}
void Do(int u){
sz=g[u].size();
if(sz<=1){
ans=max(ans,sz+1);
return;
}
v.clear(); for(auto &it : g[u]) v.emplace_back(it);
for(int i=0;i<sz;i++){
okmask[i]=1<<i;
for(int j=0;j<sz;j++) if(st.find(pii(v[i],v[j]))!=st.end()) okmask[i]|=1<<j;
}
backtrack(0,0,0);
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>deg[i];
degs.emplace(deg[i],i);
for(int u,j=1;j<=deg[i];j++){
cin>>u; u++;
st.emplace(i,u);
g[i].emplace(u);
}
}
for(int i=1;i<=n;i++){
pii tp=*degs.begin(); degs.erase(tp);
int u=tp.se;
Do(u);
ok[u]=true;
for(auto &it : g[u]){
degs.erase(pii(deg[it],it));
deg[it]--;
degs.emplace(deg[it],it);
g[it].erase(u);
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Correct |
15 ms |
6288 KB |
Output is correct |
4 |
Correct |
14 ms |
6392 KB |
Output is correct |
5 |
Correct |
14 ms |
6236 KB |
Output is correct |
6 |
Correct |
15 ms |
6264 KB |
Output is correct |
7 |
Correct |
15 ms |
6264 KB |
Output is correct |
8 |
Correct |
8 ms |
5240 KB |
Output is correct |
9 |
Correct |
6 ms |
5052 KB |
Output is correct |
10 |
Correct |
8 ms |
5240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Correct |
15 ms |
6288 KB |
Output is correct |
4 |
Correct |
14 ms |
6392 KB |
Output is correct |
5 |
Correct |
14 ms |
6236 KB |
Output is correct |
6 |
Correct |
15 ms |
6264 KB |
Output is correct |
7 |
Correct |
15 ms |
6264 KB |
Output is correct |
8 |
Correct |
8 ms |
5240 KB |
Output is correct |
9 |
Correct |
6 ms |
5052 KB |
Output is correct |
10 |
Correct |
8 ms |
5240 KB |
Output is correct |
11 |
Correct |
14 ms |
6264 KB |
Output is correct |
12 |
Correct |
14 ms |
6264 KB |
Output is correct |
13 |
Correct |
6 ms |
4984 KB |
Output is correct |
14 |
Correct |
14 ms |
6264 KB |
Output is correct |
15 |
Correct |
6 ms |
5112 KB |
Output is correct |
16 |
Correct |
14 ms |
6236 KB |
Output is correct |
17 |
Correct |
6 ms |
5112 KB |
Output is correct |
18 |
Correct |
14 ms |
6268 KB |
Output is correct |
19 |
Correct |
7 ms |
5240 KB |
Output is correct |
20 |
Correct |
11 ms |
5752 KB |
Output is correct |
21 |
Correct |
10 ms |
5752 KB |
Output is correct |
22 |
Correct |
7 ms |
5240 KB |
Output is correct |
23 |
Correct |
18 ms |
6520 KB |
Output is correct |
24 |
Correct |
8 ms |
5368 KB |
Output is correct |
25 |
Correct |
18 ms |
6648 KB |
Output is correct |
26 |
Correct |
17 ms |
6392 KB |
Output is correct |
27 |
Correct |
13 ms |
6264 KB |
Output is correct |
28 |
Correct |
16 ms |
6360 KB |
Output is correct |
29 |
Correct |
14 ms |
6264 KB |
Output is correct |
30 |
Correct |
18 ms |
6676 KB |
Output is correct |
31 |
Correct |
18 ms |
6648 KB |
Output is correct |
32 |
Correct |
18 ms |
6648 KB |
Output is correct |
33 |
Correct |
18 ms |
6648 KB |
Output is correct |
34 |
Correct |
17 ms |
6648 KB |
Output is correct |
35 |
Correct |
12 ms |
5752 KB |
Output is correct |
36 |
Correct |
12 ms |
5752 KB |
Output is correct |
37 |
Correct |
12 ms |
5752 KB |
Output is correct |
38 |
Correct |
10 ms |
5496 KB |
Output is correct |
39 |
Correct |
11 ms |
5624 KB |
Output is correct |
40 |
Correct |
28 ms |
7288 KB |
Output is correct |
41 |
Correct |
10 ms |
5624 KB |
Output is correct |
42 |
Correct |
28 ms |
7288 KB |
Output is correct |
43 |
Correct |
29 ms |
7332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5340 KB |
Output is correct |
2 |
Correct |
6 ms |
5084 KB |
Output is correct |
3 |
Correct |
6 ms |
4984 KB |
Output is correct |
4 |
Correct |
6 ms |
5084 KB |
Output is correct |
5 |
Correct |
6 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
5052 KB |
Output is correct |
7 |
Correct |
6 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4988 KB |
Output is correct |
9 |
Correct |
9 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
992 ms |
52644 KB |
Output is correct |
12 |
Correct |
6 ms |
5112 KB |
Output is correct |
13 |
Correct |
1018 ms |
52608 KB |
Output is correct |
14 |
Correct |
6 ms |
5092 KB |
Output is correct |
15 |
Correct |
1029 ms |
52628 KB |
Output is correct |
16 |
Correct |
981 ms |
52612 KB |
Output is correct |
17 |
Correct |
1000 ms |
52624 KB |
Output is correct |
18 |
Correct |
1055 ms |
52620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Correct |
15 ms |
6288 KB |
Output is correct |
4 |
Correct |
14 ms |
6392 KB |
Output is correct |
5 |
Correct |
14 ms |
6236 KB |
Output is correct |
6 |
Correct |
15 ms |
6264 KB |
Output is correct |
7 |
Correct |
15 ms |
6264 KB |
Output is correct |
8 |
Correct |
8 ms |
5240 KB |
Output is correct |
9 |
Correct |
6 ms |
5052 KB |
Output is correct |
10 |
Correct |
8 ms |
5240 KB |
Output is correct |
11 |
Correct |
14 ms |
6264 KB |
Output is correct |
12 |
Correct |
14 ms |
6264 KB |
Output is correct |
13 |
Correct |
6 ms |
4984 KB |
Output is correct |
14 |
Correct |
14 ms |
6264 KB |
Output is correct |
15 |
Correct |
6 ms |
5112 KB |
Output is correct |
16 |
Correct |
14 ms |
6236 KB |
Output is correct |
17 |
Correct |
6 ms |
5112 KB |
Output is correct |
18 |
Correct |
14 ms |
6268 KB |
Output is correct |
19 |
Correct |
7 ms |
5240 KB |
Output is correct |
20 |
Correct |
11 ms |
5752 KB |
Output is correct |
21 |
Correct |
10 ms |
5752 KB |
Output is correct |
22 |
Correct |
7 ms |
5240 KB |
Output is correct |
23 |
Correct |
18 ms |
6520 KB |
Output is correct |
24 |
Correct |
8 ms |
5368 KB |
Output is correct |
25 |
Correct |
18 ms |
6648 KB |
Output is correct |
26 |
Correct |
17 ms |
6392 KB |
Output is correct |
27 |
Correct |
13 ms |
6264 KB |
Output is correct |
28 |
Correct |
16 ms |
6360 KB |
Output is correct |
29 |
Correct |
14 ms |
6264 KB |
Output is correct |
30 |
Correct |
18 ms |
6676 KB |
Output is correct |
31 |
Correct |
18 ms |
6648 KB |
Output is correct |
32 |
Correct |
18 ms |
6648 KB |
Output is correct |
33 |
Correct |
18 ms |
6648 KB |
Output is correct |
34 |
Correct |
17 ms |
6648 KB |
Output is correct |
35 |
Correct |
12 ms |
5752 KB |
Output is correct |
36 |
Correct |
12 ms |
5752 KB |
Output is correct |
37 |
Correct |
12 ms |
5752 KB |
Output is correct |
38 |
Correct |
10 ms |
5496 KB |
Output is correct |
39 |
Correct |
11 ms |
5624 KB |
Output is correct |
40 |
Correct |
28 ms |
7288 KB |
Output is correct |
41 |
Correct |
10 ms |
5624 KB |
Output is correct |
42 |
Correct |
28 ms |
7288 KB |
Output is correct |
43 |
Correct |
29 ms |
7332 KB |
Output is correct |
44 |
Correct |
57 ms |
9308 KB |
Output is correct |
45 |
Correct |
6 ms |
5112 KB |
Output is correct |
46 |
Correct |
28 ms |
7288 KB |
Output is correct |
47 |
Correct |
57 ms |
9296 KB |
Output is correct |
48 |
Correct |
27 ms |
7288 KB |
Output is correct |
49 |
Correct |
57 ms |
9248 KB |
Output is correct |
50 |
Correct |
55 ms |
9208 KB |
Output is correct |
51 |
Correct |
146 ms |
13256 KB |
Output is correct |
52 |
Correct |
14 ms |
6264 KB |
Output is correct |
53 |
Correct |
131 ms |
14244 KB |
Output is correct |
54 |
Correct |
181 ms |
14248 KB |
Output is correct |
55 |
Correct |
14 ms |
6260 KB |
Output is correct |
56 |
Correct |
14 ms |
6236 KB |
Output is correct |
57 |
Correct |
7 ms |
5344 KB |
Output is correct |
58 |
Correct |
127 ms |
14200 KB |
Output is correct |
59 |
Correct |
24 ms |
7344 KB |
Output is correct |
60 |
Correct |
14 ms |
6380 KB |
Output is correct |
61 |
Correct |
24 ms |
7288 KB |
Output is correct |
62 |
Correct |
24 ms |
7288 KB |
Output is correct |
63 |
Correct |
58 ms |
9308 KB |
Output is correct |
64 |
Correct |
43 ms |
8696 KB |
Output is correct |
65 |
Correct |
24 ms |
7032 KB |
Output is correct |
66 |
Correct |
24 ms |
7332 KB |
Output is correct |
67 |
Correct |
72 ms |
10104 KB |
Output is correct |
68 |
Correct |
42 ms |
8696 KB |
Output is correct |
69 |
Correct |
24 ms |
7016 KB |
Output is correct |
70 |
Correct |
50 ms |
8824 KB |
Output is correct |
71 |
Correct |
81 ms |
9976 KB |
Output is correct |
72 |
Correct |
67 ms |
9848 KB |
Output is correct |
73 |
Correct |
13 ms |
6264 KB |
Output is correct |
74 |
Correct |
52 ms |
8948 KB |
Output is correct |
75 |
Correct |
69 ms |
9944 KB |
Output is correct |
76 |
Correct |
36 ms |
7908 KB |
Output is correct |
77 |
Correct |
90 ms |
11016 KB |
Output is correct |
78 |
Correct |
13 ms |
6392 KB |
Output is correct |
79 |
Correct |
44 ms |
8040 KB |
Output is correct |
80 |
Correct |
36 ms |
7928 KB |
Output is correct |
81 |
Correct |
91 ms |
11020 KB |
Output is correct |
82 |
Correct |
10 ms |
5528 KB |
Output is correct |
83 |
Correct |
44 ms |
7932 KB |
Output is correct |
84 |
Correct |
62 ms |
9708 KB |
Output is correct |
85 |
Correct |
10 ms |
5500 KB |
Output is correct |
86 |
Correct |
63 ms |
9720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Correct |
15 ms |
6288 KB |
Output is correct |
4 |
Correct |
14 ms |
6392 KB |
Output is correct |
5 |
Correct |
14 ms |
6236 KB |
Output is correct |
6 |
Correct |
15 ms |
6264 KB |
Output is correct |
7 |
Correct |
15 ms |
6264 KB |
Output is correct |
8 |
Correct |
8 ms |
5240 KB |
Output is correct |
9 |
Correct |
6 ms |
5052 KB |
Output is correct |
10 |
Correct |
8 ms |
5240 KB |
Output is correct |
11 |
Correct |
14 ms |
6264 KB |
Output is correct |
12 |
Correct |
14 ms |
6264 KB |
Output is correct |
13 |
Correct |
6 ms |
4984 KB |
Output is correct |
14 |
Correct |
14 ms |
6264 KB |
Output is correct |
15 |
Correct |
6 ms |
5112 KB |
Output is correct |
16 |
Correct |
14 ms |
6236 KB |
Output is correct |
17 |
Correct |
6 ms |
5112 KB |
Output is correct |
18 |
Correct |
14 ms |
6268 KB |
Output is correct |
19 |
Correct |
7 ms |
5240 KB |
Output is correct |
20 |
Correct |
11 ms |
5752 KB |
Output is correct |
21 |
Correct |
10 ms |
5752 KB |
Output is correct |
22 |
Correct |
7 ms |
5240 KB |
Output is correct |
23 |
Correct |
18 ms |
6520 KB |
Output is correct |
24 |
Correct |
8 ms |
5368 KB |
Output is correct |
25 |
Correct |
18 ms |
6648 KB |
Output is correct |
26 |
Correct |
17 ms |
6392 KB |
Output is correct |
27 |
Correct |
13 ms |
6264 KB |
Output is correct |
28 |
Correct |
16 ms |
6360 KB |
Output is correct |
29 |
Correct |
14 ms |
6264 KB |
Output is correct |
30 |
Correct |
18 ms |
6676 KB |
Output is correct |
31 |
Correct |
18 ms |
6648 KB |
Output is correct |
32 |
Correct |
18 ms |
6648 KB |
Output is correct |
33 |
Correct |
18 ms |
6648 KB |
Output is correct |
34 |
Correct |
17 ms |
6648 KB |
Output is correct |
35 |
Correct |
12 ms |
5752 KB |
Output is correct |
36 |
Correct |
12 ms |
5752 KB |
Output is correct |
37 |
Correct |
12 ms |
5752 KB |
Output is correct |
38 |
Correct |
10 ms |
5496 KB |
Output is correct |
39 |
Correct |
11 ms |
5624 KB |
Output is correct |
40 |
Correct |
28 ms |
7288 KB |
Output is correct |
41 |
Correct |
10 ms |
5624 KB |
Output is correct |
42 |
Correct |
28 ms |
7288 KB |
Output is correct |
43 |
Correct |
29 ms |
7332 KB |
Output is correct |
44 |
Correct |
6 ms |
4984 KB |
Output is correct |
45 |
Correct |
608 ms |
37920 KB |
Output is correct |
46 |
Correct |
220 ms |
22740 KB |
Output is correct |
47 |
Correct |
632 ms |
37720 KB |
Output is correct |
48 |
Correct |
600 ms |
37736 KB |
Output is correct |
49 |
Correct |
133 ms |
17744 KB |
Output is correct |
50 |
Correct |
547 ms |
47612 KB |
Output is correct |
51 |
Correct |
607 ms |
37760 KB |
Output is correct |
52 |
Correct |
113 ms |
17656 KB |
Output is correct |
53 |
Correct |
136 ms |
17744 KB |
Output is correct |
54 |
Correct |
25 ms |
7672 KB |
Output is correct |
55 |
Correct |
592 ms |
47620 KB |
Output is correct |
56 |
Correct |
66 ms |
12664 KB |
Output is correct |
57 |
Correct |
114 ms |
17808 KB |
Output is correct |
58 |
Correct |
183 ms |
22776 KB |
Output is correct |
59 |
Correct |
85 ms |
12664 KB |
Output is correct |
60 |
Correct |
70 ms |
12816 KB |
Output is correct |
61 |
Correct |
191 ms |
22776 KB |
Output is correct |
62 |
Correct |
125 ms |
17784 KB |
Output is correct |
63 |
Correct |
292 ms |
25208 KB |
Output is correct |
64 |
Correct |
68 ms |
12708 KB |
Output is correct |
65 |
Correct |
409 ms |
30172 KB |
Output is correct |
66 |
Correct |
120 ms |
17656 KB |
Output is correct |
67 |
Correct |
301 ms |
25320 KB |
Output is correct |
68 |
Correct |
368 ms |
28920 KB |
Output is correct |
69 |
Correct |
407 ms |
30200 KB |
Output is correct |
70 |
Correct |
119 ms |
17784 KB |
Output is correct |
71 |
Correct |
379 ms |
29024 KB |
Output is correct |
72 |
Correct |
272 ms |
24312 KB |
Output is correct |
73 |
Correct |
478 ms |
33400 KB |
Output is correct |
74 |
Correct |
119 ms |
17784 KB |
Output is correct |
75 |
Correct |
147 ms |
16248 KB |
Output is correct |
76 |
Correct |
264 ms |
24312 KB |
Output is correct |
77 |
Correct |
464 ms |
33432 KB |
Output is correct |
78 |
Correct |
199 ms |
19344 KB |
Output is correct |
79 |
Correct |
144 ms |
15992 KB |
Output is correct |
80 |
Correct |
63 ms |
10624 KB |
Output is correct |
81 |
Correct |
203 ms |
19224 KB |
Output is correct |
82 |
Correct |
334 ms |
27740 KB |
Output is correct |
83 |
Correct |
66 ms |
10616 KB |
Output is correct |
84 |
Correct |
334 ms |
27852 KB |
Output is correct |