# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
183939 | Ruxandra985 | Political Development (BOI17_politicaldevelopment) | C++14 | 538 ms | 55280 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define DIMN 50010
using namespace std;
map <int,int> mp[DIMN];
vector <int> v[DIMN];
int grad[DIMN] , f[DIMN] , l[DIMN];
pair <int,int> dp[DIMN];
priority_queue <pair <int,int> > h;
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , k , i, elem , nod , vecin , x , ok , ok2 , i2 , j , sol , val , conf;
fscanf (fin,"%d%d",&n,&k);
for (i=0;i<n;i++){
fscanf (fin,"%d",&elem);
for (j=1;j<=elem;j++){
fscanf (fin,"%d",&x);
mp[i][x] = 1;
v[i].push_back(x);
}
grad[i] = elem;
h.push(make_pair(-grad[i] , i));
}
sol = 1;
while (!h.empty()){
nod = h.top().second;
val = -h.top().first;
h.pop();
if (grad[nod] != val)
continue;
f[nod] = 1;
/// ok acum avem nodul cu cel mai mic grad
/// vrei sa vezi daca poate apartine unui graf complet
elem = 0;
for (i=0;i<v[nod].size();i++){
vecin = v[nod][i];
if (!f[vecin]) /// nu are rost sa faci heapul mai mare decat e nevoie
l[++elem] = vecin;
}
/// din graful complet curent face parte nod si un subset din l
ok = 0;
dp[++ok] = make_pair(0 , 1); /// doar nod
for (i = 1 ; i <= elem ; i++){
ok2 = ok;
for (j = 1 ; j <= ok2 ; j ++){
/// adaugi l[i] la configuratia dp[j].first
x = l[i];
conf = dp[j].first;
for (i2 = 0 ; i2 <= k ; i2++){
if ( (conf & (1 << i2)) && !mp[x][l[i2+1]] )
break;
}
if (i2 > k){
dp[++ok] = make_pair(conf + (1 << (i-1)) , dp[j].second + 1);
sol = max(sol , dp[j].second + 1);
}
}
}
/// il eliminam
for (i=0;i<v[nod].size();i++){
vecin = v[nod][i];
grad[vecin]--;
if (!f[vecin]) /// nu are rost sa faci heapul mai mare decat e nevoie
h.push(make_pair(-grad[vecin] , vecin));
}
}
fprintf (fout,"%d",sol);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |