#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
const int N=1e5+10;
const ll MOD=1e9+7;
int n,deg[N],vrj[N],ppc[N];
vector<int> g[N];
map<int,bool> mp[N];
priority_queue<pir> pq;
int kp[N],ans=1;
bool pat[N];
void solve(int k){
vector<int> v;
trav(to,g[k]){
if (deg[to])v.ad(to);
}
FOR(i,v.size()){
FOR(j,v.size()){
if (mp[v[i]][v[j]])kp[i]+=(1<<j);
}
}
//cout<<1<<endl;
//cout<<k<<endl;
pat[0]=true;
FORT(msk,1,(1<<v.size())-1){
int tv=msk-(1<<vrj[msk]);
//cout<<msk<<" "<<tv<<" "<<vrj[msk]<<" "<<kp[vrj[msk]]<<" "<<pat[tv]<<" "<<(kp[vrj[msk]]&tv)<<endl;
if (pat[tv] && ((kp[vrj[msk]]&tv)==tv)){
//cout<<"yoohoo"<<endl;
pat[msk]=true;
ans=max(ans,ppc[msk]+1);
}
else{
pat[msk]=false;
}
}
FOR(i,v.size()){
kp[i]=0;
deg[v[i]]--;
pq.push({-deg[v[i]],v[i]});
}
deg[k]=0;
}
int main(){
fastio;
srng;
FOR(msk,(1<<10)){
FOR(i,10){
if (msk&(1<<i)){
vrj[msk]=i;
ppc[msk]++;
}
}
}
int k;
cin>>n>>k;
FOR(i,n){
int d;
cin>>d;
deg[i]=d;
pq.push({-d,i});
FOR(j,d){
int to;
cin>>to;
g[i].ad(to);
mp[i][to]=true;
}
}
while(!pq.empty()){
int v,dg;
do{
v=pq.top().sc;
//cout<<v<<endl;
dg=-pq.top().fr;
pq.pop();
}while(!pq.empty() && deg[v]!=dg);
if (pq.empty())break;
//cout<<1<<endl;
solve(v);
}
cout<<ans<<endl;
return 0;
}
Compilation message
politicaldevelopment.cpp: In function 'void solve(int)':
politicaldevelopment.cpp:8:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define FOR(i,a) for (int i=0;i<(a);++i)
^
politicaldevelopment.cpp:39:5: note: in expansion of macro 'FOR'
FOR(i,v.size()){
^~~
politicaldevelopment.cpp:8:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define FOR(i,a) for (int i=0;i<(a);++i)
^
politicaldevelopment.cpp:40:9: note: in expansion of macro 'FOR'
FOR(j,v.size()){
^~~
politicaldevelopment.cpp:8:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define FOR(i,a) for (int i=0;i<(a);++i)
^
politicaldevelopment.cpp:59:5: note: in expansion of macro 'FOR'
FOR(i,v.size()){
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
10 ms |
7416 KB |
Output is correct |
3 |
Correct |
15 ms |
8356 KB |
Output is correct |
4 |
Correct |
14 ms |
8188 KB |
Output is correct |
5 |
Correct |
14 ms |
8184 KB |
Output is correct |
6 |
Correct |
14 ms |
8240 KB |
Output is correct |
7 |
Correct |
14 ms |
8184 KB |
Output is correct |
8 |
Correct |
9 ms |
7544 KB |
Output is correct |
9 |
Correct |
8 ms |
7416 KB |
Output is correct |
10 |
Correct |
9 ms |
7544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
10 ms |
7416 KB |
Output is correct |
3 |
Correct |
15 ms |
8356 KB |
Output is correct |
4 |
Correct |
14 ms |
8188 KB |
Output is correct |
5 |
Correct |
14 ms |
8184 KB |
Output is correct |
6 |
Correct |
14 ms |
8240 KB |
Output is correct |
7 |
Correct |
14 ms |
8184 KB |
Output is correct |
8 |
Correct |
9 ms |
7544 KB |
Output is correct |
9 |
Correct |
8 ms |
7416 KB |
Output is correct |
10 |
Correct |
9 ms |
7544 KB |
Output is correct |
11 |
Correct |
14 ms |
8188 KB |
Output is correct |
12 |
Correct |
14 ms |
8184 KB |
Output is correct |
13 |
Correct |
8 ms |
7416 KB |
Output is correct |
14 |
Correct |
14 ms |
8184 KB |
Output is correct |
15 |
Correct |
9 ms |
7544 KB |
Output is correct |
16 |
Correct |
14 ms |
8184 KB |
Output is correct |
17 |
Correct |
8 ms |
7416 KB |
Output is correct |
18 |
Correct |
14 ms |
8184 KB |
Output is correct |
19 |
Correct |
9 ms |
7592 KB |
Output is correct |
20 |
Correct |
11 ms |
8056 KB |
Output is correct |
21 |
Correct |
11 ms |
8056 KB |
Output is correct |
22 |
Correct |
10 ms |
7548 KB |
Output is correct |
23 |
Correct |
17 ms |
8568 KB |
Output is correct |
24 |
Correct |
9 ms |
7544 KB |
Output is correct |
25 |
Correct |
17 ms |
8568 KB |
Output is correct |
26 |
Correct |
16 ms |
8440 KB |
Output is correct |
27 |
Correct |
14 ms |
8440 KB |
Output is correct |
28 |
Correct |
16 ms |
8440 KB |
Output is correct |
29 |
Correct |
15 ms |
8440 KB |
Output is correct |
30 |
Correct |
17 ms |
8568 KB |
Output is correct |
31 |
Correct |
17 ms |
8696 KB |
Output is correct |
32 |
Correct |
16 ms |
8568 KB |
Output is correct |
33 |
Correct |
17 ms |
8696 KB |
Output is correct |
34 |
Correct |
17 ms |
8696 KB |
Output is correct |
35 |
Correct |
13 ms |
8056 KB |
Output is correct |
36 |
Correct |
12 ms |
8056 KB |
Output is correct |
37 |
Correct |
12 ms |
8056 KB |
Output is correct |
38 |
Correct |
12 ms |
7928 KB |
Output is correct |
39 |
Correct |
11 ms |
7800 KB |
Output is correct |
40 |
Correct |
22 ms |
9336 KB |
Output is correct |
41 |
Correct |
11 ms |
7800 KB |
Output is correct |
42 |
Correct |
22 ms |
9336 KB |
Output is correct |
43 |
Correct |
22 ms |
9464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7544 KB |
Output is correct |
2 |
Correct |
8 ms |
7416 KB |
Output is correct |
3 |
Correct |
9 ms |
7416 KB |
Output is correct |
4 |
Correct |
8 ms |
7488 KB |
Output is correct |
5 |
Correct |
10 ms |
7416 KB |
Output is correct |
6 |
Correct |
9 ms |
7416 KB |
Output is correct |
7 |
Correct |
8 ms |
7416 KB |
Output is correct |
8 |
Correct |
10 ms |
7416 KB |
Output is correct |
9 |
Correct |
8 ms |
7420 KB |
Output is correct |
10 |
Correct |
9 ms |
7416 KB |
Output is correct |
11 |
Correct |
694 ms |
82064 KB |
Output is correct |
12 |
Correct |
10 ms |
7416 KB |
Output is correct |
13 |
Correct |
749 ms |
82104 KB |
Output is correct |
14 |
Correct |
9 ms |
7416 KB |
Output is correct |
15 |
Correct |
696 ms |
82032 KB |
Output is correct |
16 |
Correct |
707 ms |
82144 KB |
Output is correct |
17 |
Correct |
704 ms |
82068 KB |
Output is correct |
18 |
Correct |
735 ms |
82056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
10 ms |
7416 KB |
Output is correct |
3 |
Correct |
15 ms |
8356 KB |
Output is correct |
4 |
Correct |
14 ms |
8188 KB |
Output is correct |
5 |
Correct |
14 ms |
8184 KB |
Output is correct |
6 |
Correct |
14 ms |
8240 KB |
Output is correct |
7 |
Correct |
14 ms |
8184 KB |
Output is correct |
8 |
Correct |
9 ms |
7544 KB |
Output is correct |
9 |
Correct |
8 ms |
7416 KB |
Output is correct |
10 |
Correct |
9 ms |
7544 KB |
Output is correct |
11 |
Correct |
14 ms |
8188 KB |
Output is correct |
12 |
Correct |
14 ms |
8184 KB |
Output is correct |
13 |
Correct |
8 ms |
7416 KB |
Output is correct |
14 |
Correct |
14 ms |
8184 KB |
Output is correct |
15 |
Correct |
9 ms |
7544 KB |
Output is correct |
16 |
Correct |
14 ms |
8184 KB |
Output is correct |
17 |
Correct |
8 ms |
7416 KB |
Output is correct |
18 |
Correct |
14 ms |
8184 KB |
Output is correct |
19 |
Correct |
9 ms |
7592 KB |
Output is correct |
20 |
Correct |
11 ms |
8056 KB |
Output is correct |
21 |
Correct |
11 ms |
8056 KB |
Output is correct |
22 |
Correct |
10 ms |
7548 KB |
Output is correct |
23 |
Correct |
17 ms |
8568 KB |
Output is correct |
24 |
Correct |
9 ms |
7544 KB |
Output is correct |
25 |
Correct |
17 ms |
8568 KB |
Output is correct |
26 |
Correct |
16 ms |
8440 KB |
Output is correct |
27 |
Correct |
14 ms |
8440 KB |
Output is correct |
28 |
Correct |
16 ms |
8440 KB |
Output is correct |
29 |
Correct |
15 ms |
8440 KB |
Output is correct |
30 |
Correct |
17 ms |
8568 KB |
Output is correct |
31 |
Correct |
17 ms |
8696 KB |
Output is correct |
32 |
Correct |
16 ms |
8568 KB |
Output is correct |
33 |
Correct |
17 ms |
8696 KB |
Output is correct |
34 |
Correct |
17 ms |
8696 KB |
Output is correct |
35 |
Correct |
13 ms |
8056 KB |
Output is correct |
36 |
Correct |
12 ms |
8056 KB |
Output is correct |
37 |
Correct |
12 ms |
8056 KB |
Output is correct |
38 |
Correct |
12 ms |
7928 KB |
Output is correct |
39 |
Correct |
11 ms |
7800 KB |
Output is correct |
40 |
Correct |
22 ms |
9336 KB |
Output is correct |
41 |
Correct |
11 ms |
7800 KB |
Output is correct |
42 |
Correct |
22 ms |
9336 KB |
Output is correct |
43 |
Correct |
22 ms |
9464 KB |
Output is correct |
44 |
Correct |
31 ms |
9976 KB |
Output is correct |
45 |
Correct |
9 ms |
7416 KB |
Output is correct |
46 |
Correct |
23 ms |
9464 KB |
Output is correct |
47 |
Correct |
51 ms |
12920 KB |
Output is correct |
48 |
Correct |
23 ms |
9464 KB |
Output is correct |
49 |
Correct |
49 ms |
12996 KB |
Output is correct |
50 |
Correct |
48 ms |
12916 KB |
Output is correct |
51 |
Correct |
170 ms |
25044 KB |
Output is correct |
52 |
Correct |
14 ms |
8184 KB |
Output is correct |
53 |
Correct |
72 ms |
13300 KB |
Output is correct |
54 |
Correct |
207 ms |
29036 KB |
Output is correct |
55 |
Correct |
14 ms |
8272 KB |
Output is correct |
56 |
Correct |
15 ms |
8184 KB |
Output is correct |
57 |
Correct |
9 ms |
7544 KB |
Output is correct |
58 |
Correct |
74 ms |
13316 KB |
Output is correct |
59 |
Correct |
18 ms |
8952 KB |
Output is correct |
60 |
Correct |
14 ms |
8312 KB |
Output is correct |
61 |
Correct |
18 ms |
8952 KB |
Output is correct |
62 |
Correct |
18 ms |
8824 KB |
Output is correct |
63 |
Correct |
30 ms |
9976 KB |
Output is correct |
64 |
Correct |
27 ms |
9720 KB |
Output is correct |
65 |
Correct |
21 ms |
9080 KB |
Output is correct |
66 |
Correct |
19 ms |
8824 KB |
Output is correct |
67 |
Correct |
61 ms |
14580 KB |
Output is correct |
68 |
Correct |
28 ms |
9848 KB |
Output is correct |
69 |
Correct |
22 ms |
9208 KB |
Output is correct |
70 |
Correct |
43 ms |
12152 KB |
Output is correct |
71 |
Correct |
63 ms |
14288 KB |
Output is correct |
72 |
Correct |
64 ms |
14120 KB |
Output is correct |
73 |
Correct |
27 ms |
8440 KB |
Output is correct |
74 |
Correct |
47 ms |
12056 KB |
Output is correct |
75 |
Correct |
65 ms |
14324 KB |
Output is correct |
76 |
Correct |
36 ms |
10232 KB |
Output is correct |
77 |
Correct |
96 ms |
18288 KB |
Output is correct |
78 |
Correct |
14 ms |
8440 KB |
Output is correct |
79 |
Correct |
61 ms |
12792 KB |
Output is correct |
80 |
Correct |
38 ms |
10232 KB |
Output is correct |
81 |
Correct |
92 ms |
18292 KB |
Output is correct |
82 |
Correct |
13 ms |
7928 KB |
Output is correct |
83 |
Correct |
45 ms |
12920 KB |
Output is correct |
84 |
Correct |
61 ms |
14964 KB |
Output is correct |
85 |
Correct |
13 ms |
7928 KB |
Output is correct |
86 |
Correct |
58 ms |
14836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
10 ms |
7416 KB |
Output is correct |
3 |
Correct |
15 ms |
8356 KB |
Output is correct |
4 |
Correct |
14 ms |
8188 KB |
Output is correct |
5 |
Correct |
14 ms |
8184 KB |
Output is correct |
6 |
Correct |
14 ms |
8240 KB |
Output is correct |
7 |
Correct |
14 ms |
8184 KB |
Output is correct |
8 |
Correct |
9 ms |
7544 KB |
Output is correct |
9 |
Correct |
8 ms |
7416 KB |
Output is correct |
10 |
Correct |
9 ms |
7544 KB |
Output is correct |
11 |
Correct |
14 ms |
8188 KB |
Output is correct |
12 |
Correct |
14 ms |
8184 KB |
Output is correct |
13 |
Correct |
8 ms |
7416 KB |
Output is correct |
14 |
Correct |
14 ms |
8184 KB |
Output is correct |
15 |
Correct |
9 ms |
7544 KB |
Output is correct |
16 |
Correct |
14 ms |
8184 KB |
Output is correct |
17 |
Correct |
8 ms |
7416 KB |
Output is correct |
18 |
Correct |
14 ms |
8184 KB |
Output is correct |
19 |
Correct |
9 ms |
7592 KB |
Output is correct |
20 |
Correct |
11 ms |
8056 KB |
Output is correct |
21 |
Correct |
11 ms |
8056 KB |
Output is correct |
22 |
Correct |
10 ms |
7548 KB |
Output is correct |
23 |
Correct |
17 ms |
8568 KB |
Output is correct |
24 |
Correct |
9 ms |
7544 KB |
Output is correct |
25 |
Correct |
17 ms |
8568 KB |
Output is correct |
26 |
Correct |
16 ms |
8440 KB |
Output is correct |
27 |
Correct |
14 ms |
8440 KB |
Output is correct |
28 |
Correct |
16 ms |
8440 KB |
Output is correct |
29 |
Correct |
15 ms |
8440 KB |
Output is correct |
30 |
Correct |
17 ms |
8568 KB |
Output is correct |
31 |
Correct |
17 ms |
8696 KB |
Output is correct |
32 |
Correct |
16 ms |
8568 KB |
Output is correct |
33 |
Correct |
17 ms |
8696 KB |
Output is correct |
34 |
Correct |
17 ms |
8696 KB |
Output is correct |
35 |
Correct |
13 ms |
8056 KB |
Output is correct |
36 |
Correct |
12 ms |
8056 KB |
Output is correct |
37 |
Correct |
12 ms |
8056 KB |
Output is correct |
38 |
Correct |
12 ms |
7928 KB |
Output is correct |
39 |
Correct |
11 ms |
7800 KB |
Output is correct |
40 |
Correct |
22 ms |
9336 KB |
Output is correct |
41 |
Correct |
11 ms |
7800 KB |
Output is correct |
42 |
Correct |
22 ms |
9336 KB |
Output is correct |
43 |
Correct |
22 ms |
9464 KB |
Output is correct |
44 |
Correct |
8 ms |
7416 KB |
Output is correct |
45 |
Correct |
381 ms |
42912 KB |
Output is correct |
46 |
Correct |
140 ms |
21104 KB |
Output is correct |
47 |
Correct |
392 ms |
43644 KB |
Output is correct |
48 |
Correct |
405 ms |
42996 KB |
Output is correct |
49 |
Correct |
74 ms |
15212 KB |
Output is correct |
50 |
Correct |
283 ms |
33132 KB |
Output is correct |
51 |
Correct |
378 ms |
43620 KB |
Output is correct |
52 |
Correct |
71 ms |
15216 KB |
Output is correct |
53 |
Correct |
74 ms |
15216 KB |
Output is correct |
54 |
Correct |
19 ms |
8312 KB |
Output is correct |
55 |
Correct |
302 ms |
33136 KB |
Output is correct |
56 |
Correct |
55 ms |
13552 KB |
Output is correct |
57 |
Correct |
74 ms |
15216 KB |
Output is correct |
58 |
Correct |
106 ms |
19312 KB |
Output is correct |
59 |
Correct |
51 ms |
13424 KB |
Output is correct |
60 |
Correct |
55 ms |
13424 KB |
Output is correct |
61 |
Correct |
105 ms |
19316 KB |
Output is correct |
62 |
Correct |
80 ms |
16472 KB |
Output is correct |
63 |
Correct |
178 ms |
24340 KB |
Output is correct |
64 |
Correct |
52 ms |
13552 KB |
Output is correct |
65 |
Correct |
240 ms |
30700 KB |
Output is correct |
66 |
Correct |
78 ms |
16492 KB |
Output is correct |
67 |
Correct |
175 ms |
24304 KB |
Output is correct |
68 |
Correct |
221 ms |
29416 KB |
Output is correct |
69 |
Correct |
240 ms |
30760 KB |
Output is correct |
70 |
Correct |
87 ms |
17388 KB |
Output is correct |
71 |
Correct |
224 ms |
29516 KB |
Output is correct |
72 |
Correct |
178 ms |
23560 KB |
Output is correct |
73 |
Correct |
365 ms |
36884 KB |
Output is correct |
74 |
Correct |
90 ms |
17392 KB |
Output is correct |
75 |
Correct |
94 ms |
17520 KB |
Output is correct |
76 |
Correct |
176 ms |
23660 KB |
Output is correct |
77 |
Correct |
283 ms |
36944 KB |
Output is correct |
78 |
Correct |
131 ms |
22256 KB |
Output is correct |
79 |
Correct |
94 ms |
17420 KB |
Output is correct |
80 |
Correct |
47 ms |
11892 KB |
Output is correct |
81 |
Correct |
136 ms |
22276 KB |
Output is correct |
82 |
Correct |
199 ms |
28364 KB |
Output is correct |
83 |
Correct |
46 ms |
11892 KB |
Output is correct |
84 |
Correct |
203 ms |
28392 KB |
Output is correct |