# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260448 | dolphingarlic | Political Development (BOI17_politicaldevelopment) | C++14 | 1864 ms | 24568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
set<int> graph[50000];
bool tried[50000];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
queue<int> q;
for (int i = 0; i < n; i++) {
int s;
cin >> s;
if (s < k) {
tried[i] = true;
q.push(i);
}
while (s--) {
int b;
cin >> b;
graph[i].insert(b);
}
}
int ans = 0;
while (q.size()) {
int curr = q.front();
q.pop();
for (int i = 0; i < (1 << graph[curr].size()); i++) {
if (__builtin_popcount(i) <= ans) continue;
vector<int> adj;
int tmp = i;
for (int j : graph[curr]) {
if (tmp & 1) adj.push_back(j);
tmp >>= 1;
}
bool good = true;
for (int j = 0; j < adj.size(); j++) {
for (int l = j + 1; l < adj.size(); l++) {
good &= graph[adj[j]].find(adj[l]) != graph[adj[j]].end();
}
}
if (good) ans = __builtin_popcount(i);
}
for (int i : graph[curr]) {
graph[i].erase(curr);
if (!tried[i] && graph[i].size() < k) {
tried[i] = true;
q.push(i);
}
}
graph[curr].clear();
}
cout << ans + 1;
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... |