# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
783107 | 2023-07-14T15:31:30 Z | 1075508020060209tc | Political Development (BOI17_politicaldevelopment) | C++14 | 908 ms | 26144 KB |
#include<bits/stdc++.h> using namespace std; //#define int long long #define X first #define Y second int n;int K; set<int>st[50100]; int tbl[5010][5010]; void slvk3(){ int ans=1; for(int i=0;i<=n-1;i++){ if(st[i].size()>=2){ans=2;break;} } for(int i=0;i<=n-1;i++){ for(auto it=st[i].begin();(*it)<i;it++){ int v=(*it); } } } signed main(){ cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>K; for(int i=0;i<n;i++){ int d; cin>>d; for(int j=1;j<=d;j++){ int v; cin>>v; if(v<i){ if(st[v].find(i)==st[v].end()){continue;} } st[i].insert(v); // tbl[i][v]=1; } // tbl[i][i]=1; st[i].insert(i); } if(K<=3){ //slvk3(); } for(int i=n-1;i>=0;i--){ vector<int>vc; for(auto it=st[i].begin();it!=st[i].end();it++){ int v=*it; if(v>i){ if(st[v].find(i)==st[v].end()){vc.push_back(v);} } } for(int j=0;j<vc.size();j++){ st[i].erase(vc[j]); } } int ans=1; for(int i=0;i<n;i++){ vector<int>vc; for(auto it=st[i].begin();it!=st[i].end();it++){ vc.push_back(*it); } if(vc.size()>12 ){continue;} for(int A=0;A<(1<<vc.size());A++){ if(__builtin_popcount(A)<=ans){continue;} if(__builtin_popcount(A)>K){continue;} if(__builtin_popcount(A)>ans+1){continue;} int ok=1; // cout<<A<<"A\n"; for(int j=0;j<vc.size();j++){ // cout<<vc[j]<<" "<<ok<<endl;; if(!ok){break;} if(((A&(1<<j))!=0)){ for(int k=0;k<vc.size();k++){ if(!ok){break;} if( ((A&(1<<k))==0) ){continue;} //cout<<A<<" "<<k<<endl; if(st[vc[j]].find(vc[k])==st[vc[j]].end()){ok=0;} // cout<<A<<" "<<vc[j]<<" "<<vc[k]; //if(tbl[vc[j]][vc[k]]==0){ok=0;} //cout<<" "<<ok<<endl; } } } //cout<<ok<<endl; if((ok&&(__builtin_popcount(A)>ans)) ){ ans=__builtin_popcount(A); if(ans==K){ cout<<K;return 0; } } } } cout<<ans<<endl; //return 0; /* for(int i=0;i<ans.size();i++){ cout<<ans[i]<<" "; }*/ }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 3 ms | 3284 KB | Output is correct |
4 | Correct | 5 ms | 3284 KB | Output is correct |
5 | Correct | 4 ms | 3320 KB | Output is correct |
6 | Correct | 4 ms | 3284 KB | Output is correct |
7 | Correct | 3 ms | 3328 KB | Output is correct |
8 | Correct | 2 ms | 2832 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 3 ms | 3284 KB | Output is correct |
4 | Correct | 5 ms | 3284 KB | Output is correct |
5 | Correct | 4 ms | 3320 KB | Output is correct |
6 | Correct | 4 ms | 3284 KB | Output is correct |
7 | Correct | 3 ms | 3328 KB | Output is correct |
8 | Correct | 2 ms | 2832 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
11 | Correct | 3 ms | 3284 KB | Output is correct |
12 | Correct | 4 ms | 3392 KB | Output is correct |
13 | Correct | 1 ms | 2644 KB | Output is correct |
14 | Correct | 5 ms | 3412 KB | Output is correct |
15 | Correct | 1 ms | 2644 KB | Output is correct |
16 | Correct | 5 ms | 3392 KB | Output is correct |
17 | Correct | 2 ms | 2644 KB | Output is correct |
18 | Correct | 6 ms | 3360 KB | Output is correct |
19 | Correct | 3 ms | 2900 KB | Output is correct |
20 | Correct | 3 ms | 3064 KB | Output is correct |
21 | Correct | 2 ms | 3028 KB | Output is correct |
22 | Correct | 2 ms | 2900 KB | Output is correct |
23 | Correct | 4 ms | 3412 KB | Output is correct |
24 | Correct | 2 ms | 2900 KB | Output is correct |
25 | Correct | 4 ms | 3412 KB | Output is correct |
26 | Correct | 6 ms | 3400 KB | Output is correct |
27 | Correct | 4 ms | 3284 KB | Output is correct |
28 | Correct | 5 ms | 3412 KB | Output is correct |
29 | Correct | 4 ms | 3284 KB | Output is correct |
30 | Correct | 5 ms | 3540 KB | Output is correct |
31 | Correct | 5 ms | 3536 KB | Output is correct |
32 | Correct | 5 ms | 3540 KB | Output is correct |
33 | Correct | 7 ms | 3536 KB | Output is correct |
34 | Correct | 5 ms | 3536 KB | Output is correct |
35 | Correct | 3 ms | 3028 KB | Output is correct |
36 | Correct | 5 ms | 3096 KB | Output is correct |
37 | Correct | 4 ms | 3028 KB | Output is correct |
38 | Correct | 4 ms | 2900 KB | Output is correct |
39 | Correct | 3 ms | 2900 KB | Output is correct |
40 | Correct | 8 ms | 3924 KB | Output is correct |
41 | Correct | 3 ms | 2900 KB | Output is correct |
42 | Correct | 7 ms | 3740 KB | Output is correct |
43 | Correct | 5 ms | 3796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2900 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 1 ms | 2644 KB | Output is correct |
4 | Correct | 1 ms | 2644 KB | Output is correct |
5 | Correct | 1 ms | 2644 KB | Output is correct |
6 | Correct | 1 ms | 2644 KB | Output is correct |
7 | Correct | 1 ms | 2644 KB | Output is correct |
8 | Correct | 1 ms | 2644 KB | Output is correct |
9 | Correct | 2 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2584 KB | Output is correct |
11 | Correct | 908 ms | 26024 KB | Output is correct |
12 | Correct | 1 ms | 2644 KB | Output is correct |
13 | Correct | 426 ms | 26140 KB | Output is correct |
14 | Correct | 1 ms | 2644 KB | Output is correct |
15 | Correct | 860 ms | 26140 KB | Output is correct |
16 | Correct | 450 ms | 26144 KB | Output is correct |
17 | Correct | 463 ms | 26144 KB | Output is correct |
18 | Correct | 507 ms | 26060 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 3 ms | 3284 KB | Output is correct |
4 | Correct | 5 ms | 3284 KB | Output is correct |
5 | Correct | 4 ms | 3320 KB | Output is correct |
6 | Correct | 4 ms | 3284 KB | Output is correct |
7 | Correct | 3 ms | 3328 KB | Output is correct |
8 | Correct | 2 ms | 2832 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
11 | Correct | 3 ms | 3284 KB | Output is correct |
12 | Correct | 4 ms | 3392 KB | Output is correct |
13 | Correct | 1 ms | 2644 KB | Output is correct |
14 | Correct | 5 ms | 3412 KB | Output is correct |
15 | Correct | 1 ms | 2644 KB | Output is correct |
16 | Correct | 5 ms | 3392 KB | Output is correct |
17 | Correct | 2 ms | 2644 KB | Output is correct |
18 | Correct | 6 ms | 3360 KB | Output is correct |
19 | Correct | 3 ms | 2900 KB | Output is correct |
20 | Correct | 3 ms | 3064 KB | Output is correct |
21 | Correct | 2 ms | 3028 KB | Output is correct |
22 | Correct | 2 ms | 2900 KB | Output is correct |
23 | Correct | 4 ms | 3412 KB | Output is correct |
24 | Correct | 2 ms | 2900 KB | Output is correct |
25 | Correct | 4 ms | 3412 KB | Output is correct |
26 | Correct | 6 ms | 3400 KB | Output is correct |
27 | Correct | 4 ms | 3284 KB | Output is correct |
28 | Correct | 5 ms | 3412 KB | Output is correct |
29 | Correct | 4 ms | 3284 KB | Output is correct |
30 | Correct | 5 ms | 3540 KB | Output is correct |
31 | Correct | 5 ms | 3536 KB | Output is correct |
32 | Correct | 5 ms | 3540 KB | Output is correct |
33 | Correct | 7 ms | 3536 KB | Output is correct |
34 | Correct | 5 ms | 3536 KB | Output is correct |
35 | Correct | 3 ms | 3028 KB | Output is correct |
36 | Correct | 5 ms | 3096 KB | Output is correct |
37 | Correct | 4 ms | 3028 KB | Output is correct |
38 | Correct | 4 ms | 2900 KB | Output is correct |
39 | Correct | 3 ms | 2900 KB | Output is correct |
40 | Correct | 8 ms | 3924 KB | Output is correct |
41 | Correct | 3 ms | 2900 KB | Output is correct |
42 | Correct | 7 ms | 3740 KB | Output is correct |
43 | Correct | 5 ms | 3796 KB | Output is correct |
44 | Correct | 11 ms | 4792 KB | Output is correct |
45 | Correct | 2 ms | 2644 KB | Output is correct |
46 | Correct | 14 ms | 3852 KB | Output is correct |
47 | Incorrect | 37 ms | 4692 KB | Output isn't correct |
48 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 3 ms | 3284 KB | Output is correct |
4 | Correct | 5 ms | 3284 KB | Output is correct |
5 | Correct | 4 ms | 3320 KB | Output is correct |
6 | Correct | 4 ms | 3284 KB | Output is correct |
7 | Correct | 3 ms | 3328 KB | Output is correct |
8 | Correct | 2 ms | 2832 KB | Output is correct |
9 | Correct | 1 ms | 2644 KB | Output is correct |
10 | Correct | 2 ms | 2900 KB | Output is correct |
11 | Correct | 3 ms | 3284 KB | Output is correct |
12 | Correct | 4 ms | 3392 KB | Output is correct |
13 | Correct | 1 ms | 2644 KB | Output is correct |
14 | Correct | 5 ms | 3412 KB | Output is correct |
15 | Correct | 1 ms | 2644 KB | Output is correct |
16 | Correct | 5 ms | 3392 KB | Output is correct |
17 | Correct | 2 ms | 2644 KB | Output is correct |
18 | Correct | 6 ms | 3360 KB | Output is correct |
19 | Correct | 3 ms | 2900 KB | Output is correct |
20 | Correct | 3 ms | 3064 KB | Output is correct |
21 | Correct | 2 ms | 3028 KB | Output is correct |
22 | Correct | 2 ms | 2900 KB | Output is correct |
23 | Correct | 4 ms | 3412 KB | Output is correct |
24 | Correct | 2 ms | 2900 KB | Output is correct |
25 | Correct | 4 ms | 3412 KB | Output is correct |
26 | Correct | 6 ms | 3400 KB | Output is correct |
27 | Correct | 4 ms | 3284 KB | Output is correct |
28 | Correct | 5 ms | 3412 KB | Output is correct |
29 | Correct | 4 ms | 3284 KB | Output is correct |
30 | Correct | 5 ms | 3540 KB | Output is correct |
31 | Correct | 5 ms | 3536 KB | Output is correct |
32 | Correct | 5 ms | 3540 KB | Output is correct |
33 | Correct | 7 ms | 3536 KB | Output is correct |
34 | Correct | 5 ms | 3536 KB | Output is correct |
35 | Correct | 3 ms | 3028 KB | Output is correct |
36 | Correct | 5 ms | 3096 KB | Output is correct |
37 | Correct | 4 ms | 3028 KB | Output is correct |
38 | Correct | 4 ms | 2900 KB | Output is correct |
39 | Correct | 3 ms | 2900 KB | Output is correct |
40 | Correct | 8 ms | 3924 KB | Output is correct |
41 | Correct | 3 ms | 2900 KB | Output is correct |
42 | Correct | 7 ms | 3740 KB | Output is correct |
43 | Correct | 5 ms | 3796 KB | Output is correct |
44 | Correct | 1 ms | 2644 KB | Output is correct |
45 | Incorrect | 332 ms | 19108 KB | Output isn't correct |
46 | Halted | 0 ms | 0 KB | - |