제출 #260448

#제출 시각아이디문제언어결과실행 시간메모리
260448dolphingarlicPolitical Development (BOI17_politicaldevelopment)C++14
100 / 100
1864 ms24568 KiB
#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) 메시지

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < adj.size(); j++) {
                    ~~^~~~~~~~~~~~
politicaldevelopment.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int l = j + 1; l < adj.size(); l++) {
                         ~~^~~~~~~~~~~~
politicaldevelopment.cpp:52:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (!tried[i] && graph[i].size() < k) {
                     ~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...