제출 #825242

#제출 시각아이디문제언어결과실행 시간메모리
825242QwertyPiPolitical Development (BOI17_politicaldevelopment)C++14
100 / 100
566 ms28656 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e4 + 11; const int MAXK = 10; bool done[MAXN]; set<int> G[MAXN]; template<class T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; int ans = 1; bool can(const vector<int>& v){ for(int i = 0; i < v.size(); i++){ for(int j = i + 1; j < v.size(); j++){ if(!G[v[i]].count(v[j])) return false; } } return true; } void check(const vector<int>& v){ bool ok = can(v); if(ok) ans = max(ans, (int) v.size()); } int32_t main(){ int n, k; cin >> n >> k; for(int i = 0; i < n; i++){ int d; cin >> d; for(int j = 0; j < d; j++){ int v; cin >> v; G[i].insert(v); } } min_priority_queue<pair<int, int>> pq; for(int i = 1; i <= n; i++){ pq.push({G[i].size(), i}); } while(!pq.empty()){ auto [d, v] = pq.top(); pq.pop(); if(G[v].size() != d || done[v]) continue; done[v] = true; vector<int> adj {G[v].begin(), G[v].end()}; for(int i = 0; i < (1 << d); i++){ vector<int> ch {v}; for(int j = 0; j < d; j++){ if(i & (1 << j)) ch.push_back(adj[j]); } check(ch); } for(auto u : G[v]){ if(G[u].count(v)) G[u].erase(v); pq.push({G[u].size(), u}); } } cout << ans << endl; }

컴파일 시 표준 에러 (stderr) 메시지

politicaldevelopment.cpp: In function 'bool can(const std::vector<int>&)':
politicaldevelopment.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < v.size(); i++){
      |                 ~~^~~~~~~~~~
politicaldevelopment.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int j = i + 1; j < v.size(); j++){
      |                      ~~^~~~~~~~~~
politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:44:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |   auto [d, v] = pq.top(); pq.pop();
      |        ^
politicaldevelopment.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} [-Wsign-compare]
   45 |   if(G[v].size() != d || done[v]) continue;
      |      ~~~~~~~~~~~~^~~~
#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...