# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
744095 | 2023-05-18T08:03:45 Z | MilosMilutinovic | Political Development (BOI17_politicaldevelopment) | C++14 | 73 ms | 1784 KB |
#include <bits/stdc++.h> using namespace std; int n,k,id[50005]; vector<int> g[50005]; signed main() { scanf("%d%d",&n,&k); for(int d,i=0;i<n;i++) { scanf("%d",&d); for(int x,j=0;j<d;j++) { scanf("%d",&x); g[i].push_back(x); g[x].push_back(i); } } for(int i=0;i<n;i++) id[i]=-1; int ans=1; for(int i=0;i<n;i++) { int deg=(int)g[i].size(); if (deg>k) continue; for(int j=0;j<deg;j++) id[g[i][j]]=j+1; id[i]=0; deg++; vector<int> a; a.push_back((1<<deg)-1); for(int x:g[i]) { int f=(1<<id[x]); for(int y:g[x]) if(id[y]!=-1) f+=(1<<id[y]); a.push_back(f); } for(int mask=0;mask<(1<<deg);mask++) { bool ok=true; for(int j=0;j<deg;j++) if(mask>>j&1) if((mask&a[j])!=mask) ok=false; if(ok) ans=max(ans,__builtin_popcount(mask)); } for(int j=0;j<deg-1;j++) id[g[i][j]]=-1; id[i]=-1; } printf("%d\n",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1364 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 4 ms | 1620 KB | Output is correct |
4 | Correct | 73 ms | 1784 KB | Output is correct |
5 | Correct | 72 ms | 1768 KB | Output is correct |
6 | Correct | 6 ms | 1748 KB | Output is correct |
7 | Correct | 5 ms | 1748 KB | Output is correct |
8 | Correct | 2 ms | 1492 KB | Output is correct |
9 | Correct | 1 ms | 1476 KB | Output is correct |
10 | Correct | 2 ms | 1492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1364 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 4 ms | 1620 KB | Output is correct |
4 | Correct | 73 ms | 1784 KB | Output is correct |
5 | Correct | 72 ms | 1768 KB | Output is correct |
6 | Correct | 6 ms | 1748 KB | Output is correct |
7 | Correct | 5 ms | 1748 KB | Output is correct |
8 | Correct | 2 ms | 1492 KB | Output is correct |
9 | Correct | 1 ms | 1476 KB | Output is correct |
10 | Correct | 2 ms | 1492 KB | Output is correct |
11 | Correct | 73 ms | 1784 KB | Output is correct |
12 | Correct | 73 ms | 1728 KB | Output is correct |
13 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1364 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 4 ms | 1620 KB | Output is correct |
4 | Correct | 73 ms | 1784 KB | Output is correct |
5 | Correct | 72 ms | 1768 KB | Output is correct |
6 | Correct | 6 ms | 1748 KB | Output is correct |
7 | Correct | 5 ms | 1748 KB | Output is correct |
8 | Correct | 2 ms | 1492 KB | Output is correct |
9 | Correct | 1 ms | 1476 KB | Output is correct |
10 | Correct | 2 ms | 1492 KB | Output is correct |
11 | Correct | 73 ms | 1784 KB | Output is correct |
12 | Correct | 73 ms | 1728 KB | Output is correct |
13 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1364 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 4 ms | 1620 KB | Output is correct |
4 | Correct | 73 ms | 1784 KB | Output is correct |
5 | Correct | 72 ms | 1768 KB | Output is correct |
6 | Correct | 6 ms | 1748 KB | Output is correct |
7 | Correct | 5 ms | 1748 KB | Output is correct |
8 | Correct | 2 ms | 1492 KB | Output is correct |
9 | Correct | 1 ms | 1476 KB | Output is correct |
10 | Correct | 2 ms | 1492 KB | Output is correct |
11 | Correct | 73 ms | 1784 KB | Output is correct |
12 | Correct | 73 ms | 1728 KB | Output is correct |
13 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |