#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxN=5e4+5; //make sure this is right
const int mod=1e9+7;
int n,k,deg[mxN],seen[mxN];
set<int> graph[mxN];
int main(){
cin.sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
cin>>n>>k;
priority_queue<pii,vector<pii>,greater<pii>> q;
for(int i=0;i<n;i++){
cin>>deg[i];
for(int j=0;j<deg[i];j++){
int x; cin>>x;
graph[i].insert(x);
}
q.push({deg[i],i});
}
int ans=1;
while(sz(q)){
pii cur=q.top(); q.pop();
if(cur.first!=deg[cur.second])
continue;
int at=cur.second;
seen[at]=1;
vector<int> nd={at};
for(int i:graph[at]){
if(!seen[i]){
deg[i]--;
q.push({deg[i],i});
nd.pb(i);
}
}
for(int mask=0;mask<(1<<sz(nd));mask++){
int yes=1;
for(int i=0;i<sz(nd);i++){
if(!(mask&(1<<i)))
continue;
for(int j=0;j<sz(nd);j++){
if(!(mask&(1<<j)))
continue;
if(i==j)
continue;
yes&=(graph[nd[i]].count(nd[j]));
yes&=(graph[nd[j]].count(nd[i]));
}
}
if(yes)
maxa(ans,__builtin_popcount(mask));
}
}
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3216 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3216 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
6 ms |
3148 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3148 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3148 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
6 ms |
3148 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
5 ms |
2892 KB |
Output is correct |
21 |
Correct |
5 ms |
2892 KB |
Output is correct |
22 |
Correct |
3 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3344 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3276 KB |
Output is correct |
27 |
Correct |
6 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3260 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
9 ms |
3276 KB |
Output is correct |
31 |
Correct |
8 ms |
3280 KB |
Output is correct |
32 |
Correct |
10 ms |
3392 KB |
Output is correct |
33 |
Correct |
8 ms |
3368 KB |
Output is correct |
34 |
Correct |
8 ms |
3384 KB |
Output is correct |
35 |
Correct |
5 ms |
3020 KB |
Output is correct |
36 |
Correct |
5 ms |
3020 KB |
Output is correct |
37 |
Correct |
5 ms |
3024 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
4 ms |
2892 KB |
Output is correct |
40 |
Correct |
12 ms |
3788 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
13 ms |
3700 KB |
Output is correct |
43 |
Correct |
12 ms |
3788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2764 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2636 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
2 ms |
2636 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
2 ms |
2636 KB |
Output is correct |
11 |
Correct |
2198 ms |
26204 KB |
Output is correct |
12 |
Correct |
2 ms |
2636 KB |
Output is correct |
13 |
Correct |
2209 ms |
26232 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
2217 ms |
26228 KB |
Output is correct |
16 |
Correct |
2171 ms |
26152 KB |
Output is correct |
17 |
Correct |
2172 ms |
26172 KB |
Output is correct |
18 |
Correct |
2169 ms |
26344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3216 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
6 ms |
3148 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3148 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3148 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
6 ms |
3148 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
5 ms |
2892 KB |
Output is correct |
21 |
Correct |
5 ms |
2892 KB |
Output is correct |
22 |
Correct |
3 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3344 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3276 KB |
Output is correct |
27 |
Correct |
6 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3260 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
9 ms |
3276 KB |
Output is correct |
31 |
Correct |
8 ms |
3280 KB |
Output is correct |
32 |
Correct |
10 ms |
3392 KB |
Output is correct |
33 |
Correct |
8 ms |
3368 KB |
Output is correct |
34 |
Correct |
8 ms |
3384 KB |
Output is correct |
35 |
Correct |
5 ms |
3020 KB |
Output is correct |
36 |
Correct |
5 ms |
3020 KB |
Output is correct |
37 |
Correct |
5 ms |
3024 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
4 ms |
2892 KB |
Output is correct |
40 |
Correct |
12 ms |
3788 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
13 ms |
3700 KB |
Output is correct |
43 |
Correct |
12 ms |
3788 KB |
Output is correct |
44 |
Correct |
308 ms |
4612 KB |
Output is correct |
45 |
Correct |
2 ms |
2636 KB |
Output is correct |
46 |
Correct |
15 ms |
3720 KB |
Output is correct |
47 |
Correct |
80 ms |
4856 KB |
Output is correct |
48 |
Correct |
15 ms |
3704 KB |
Output is correct |
49 |
Correct |
79 ms |
4908 KB |
Output is correct |
50 |
Correct |
91 ms |
4864 KB |
Output is correct |
51 |
Correct |
1994 ms |
7556 KB |
Output is correct |
52 |
Correct |
6 ms |
3148 KB |
Output is correct |
53 |
Execution timed out |
3100 ms |
7208 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
3148 KB |
Output is correct |
4 |
Correct |
7 ms |
3216 KB |
Output is correct |
5 |
Correct |
6 ms |
3148 KB |
Output is correct |
6 |
Correct |
6 ms |
3148 KB |
Output is correct |
7 |
Correct |
6 ms |
3148 KB |
Output is correct |
8 |
Correct |
3 ms |
2764 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
3 ms |
2764 KB |
Output is correct |
11 |
Correct |
6 ms |
3148 KB |
Output is correct |
12 |
Correct |
6 ms |
3148 KB |
Output is correct |
13 |
Correct |
2 ms |
2636 KB |
Output is correct |
14 |
Correct |
6 ms |
3148 KB |
Output is correct |
15 |
Correct |
2 ms |
2636 KB |
Output is correct |
16 |
Correct |
6 ms |
3148 KB |
Output is correct |
17 |
Correct |
2 ms |
2636 KB |
Output is correct |
18 |
Correct |
6 ms |
3148 KB |
Output is correct |
19 |
Correct |
3 ms |
2764 KB |
Output is correct |
20 |
Correct |
5 ms |
2892 KB |
Output is correct |
21 |
Correct |
5 ms |
2892 KB |
Output is correct |
22 |
Correct |
3 ms |
2764 KB |
Output is correct |
23 |
Correct |
8 ms |
3344 KB |
Output is correct |
24 |
Correct |
3 ms |
2764 KB |
Output is correct |
25 |
Correct |
8 ms |
3276 KB |
Output is correct |
26 |
Correct |
7 ms |
3276 KB |
Output is correct |
27 |
Correct |
6 ms |
3148 KB |
Output is correct |
28 |
Correct |
7 ms |
3260 KB |
Output is correct |
29 |
Correct |
6 ms |
3148 KB |
Output is correct |
30 |
Correct |
9 ms |
3276 KB |
Output is correct |
31 |
Correct |
8 ms |
3280 KB |
Output is correct |
32 |
Correct |
10 ms |
3392 KB |
Output is correct |
33 |
Correct |
8 ms |
3368 KB |
Output is correct |
34 |
Correct |
8 ms |
3384 KB |
Output is correct |
35 |
Correct |
5 ms |
3020 KB |
Output is correct |
36 |
Correct |
5 ms |
3020 KB |
Output is correct |
37 |
Correct |
5 ms |
3024 KB |
Output is correct |
38 |
Correct |
4 ms |
2892 KB |
Output is correct |
39 |
Correct |
4 ms |
2892 KB |
Output is correct |
40 |
Correct |
12 ms |
3788 KB |
Output is correct |
41 |
Correct |
4 ms |
2892 KB |
Output is correct |
42 |
Correct |
13 ms |
3700 KB |
Output is correct |
43 |
Correct |
12 ms |
3788 KB |
Output is correct |
44 |
Correct |
2 ms |
2636 KB |
Output is correct |
45 |
Correct |
330 ms |
19188 KB |
Output is correct |
46 |
Correct |
100 ms |
10592 KB |
Output is correct |
47 |
Correct |
358 ms |
19176 KB |
Output is correct |
48 |
Correct |
331 ms |
19404 KB |
Output is correct |
49 |
Correct |
56 ms |
8124 KB |
Output is correct |
50 |
Correct |
826 ms |
23776 KB |
Output is correct |
51 |
Correct |
354 ms |
19128 KB |
Output is correct |
52 |
Correct |
56 ms |
8060 KB |
Output is correct |
53 |
Correct |
56 ms |
8092 KB |
Output is correct |
54 |
Correct |
12 ms |
3488 KB |
Output is correct |
55 |
Correct |
830 ms |
23728 KB |
Output is correct |
56 |
Correct |
28 ms |
5700 KB |
Output is correct |
57 |
Correct |
51 ms |
8100 KB |
Output is correct |
58 |
Correct |
71 ms |
10484 KB |
Output is correct |
59 |
Correct |
28 ms |
5744 KB |
Output is correct |
60 |
Correct |
28 ms |
5716 KB |
Output is correct |
61 |
Correct |
72 ms |
10428 KB |
Output is correct |
62 |
Correct |
48 ms |
8088 KB |
Output is correct |
63 |
Correct |
115 ms |
12292 KB |
Output is correct |
64 |
Correct |
28 ms |
5696 KB |
Output is correct |
65 |
Correct |
190 ms |
14588 KB |
Output is correct |
66 |
Correct |
47 ms |
8092 KB |
Output is correct |
67 |
Correct |
111 ms |
12240 KB |
Output is correct |
68 |
Correct |
168 ms |
13948 KB |
Output is correct |
69 |
Correct |
192 ms |
14636 KB |
Output is correct |
70 |
Correct |
48 ms |
8132 KB |
Output is correct |
71 |
Correct |
172 ms |
14004 KB |
Output is correct |
72 |
Correct |
132 ms |
11904 KB |
Output is correct |
73 |
Correct |
238 ms |
16060 KB |
Output is correct |
74 |
Correct |
48 ms |
8072 KB |
Output is correct |
75 |
Correct |
62 ms |
7848 KB |
Output is correct |
76 |
Correct |
125 ms |
11832 KB |
Output is correct |
77 |
Correct |
231 ms |
16120 KB |
Output is correct |
78 |
Correct |
118 ms |
9404 KB |
Output is correct |
79 |
Correct |
62 ms |
7852 KB |
Output is correct |
80 |
Correct |
34 ms |
5324 KB |
Output is correct |
81 |
Correct |
114 ms |
9408 KB |
Output is correct |
82 |
Correct |
135 ms |
13372 KB |
Output is correct |
83 |
Correct |
35 ms |
5324 KB |
Output is correct |
84 |
Correct |
134 ms |
13376 KB |
Output is correct |