# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
136808 | kdh9949 | Political Development (BOI17_politicaldevelopment) | C++17 | 528 ms | 20472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int n, k, d[50010], chk[50010], pro[50010], vs, a[11][11], ans;
set<pii> ss;
vector<int> e[50010], v, cv;
queue<int> q;
int btk(int t){
if(t == vs) return cv.size();
int ret = btk(t + 1);
if(!cv.empty()) for(auto &j : cv) if(!a[j][t]) return ret;
cv.push_back(t);
ret = max(ret, btk(t + 1));
cv.pop_back();
return ret;
}
int get(int x){
v.clear();
v.push_back(x);
if(e[x].empty()) return 1;
for(auto &i : e[x]){
if(!pro[i]) v.push_back(i);
}
sort(v.begin(), v.end());
vs = int(v.size());
if(vs <= 2) return vs;
for(int i = 0; i < vs; i++){
for(int j = 0; j < vs; j++){
a[i][j] = (ss.find({v[i], v[j]}) != ss.end());
}
}
return btk(0);
}
int main(){
scanf("%d%d", &n, &k);
for(int i = 1, t; i <= n; i++){
scanf("%d", &t);
for(int x; t--; ){
scanf("%d", &x); x++;
if(i < x){
ss.insert({i, x});
e[i].push_back(x);
e[x].push_back(i);
d[i]++; d[x]++;
}
}
}
for(int i = 1; i <= n; i++){
if(d[i] < k){
q.push(i);
chk[i] = 1;
}
}
for(int t = n - k + 1; t--;){
int cur = q.front(); q.pop();
ans = max(ans, get(cur));
pro[cur] = 1;
if(!e[cur].empty()){
for(auto &j : e[cur]){
d[j]--;
if(!chk[j] && d[j] < k){
q.push(j);
chk[j] = 1;
}
}
}
}
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... |