이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 50000;
int n, k;
int deg[N];
vector<int> g[N];
bitset<N> yes[N];
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int> > > pq;
for(int i = 0;i < n; i++){
int sz; cin >> sz;
deg[i] = sz;
pq.push({deg[i], i});
yes[i][i] = 1;
for(int j = 0;j < sz; j++){
int x; cin >> x;
yes[i][x] = 1;
g[i].push_back(x);
}
}
int ans = 1;
vector<int> used(n, 0);
while(true){
while(!pq.empty() && used[pq.top().ss]) pq.pop();
if(pq.empty()) break;
int v = pq.top().ss;
pq.pop();
used[v] = 1;
deg[v] = 0;
vector<int> vert = {v};
for(int to : g[v]){
if(used[to]) continue;
deg[to]--;
pq.push({deg[to], to});
vert.push_back(to);
}
for(int mask = 1; mask < (1<<vert.size()); mask++){
int ok = 1, cnt = 0;
for(int i = 0;i < vert.size() && ok; i++){
if(!(mask & (1<<i))) continue;
cnt++;
for(int j = 0;j < vert.size(); j++){
if(mask & (1<<j)){
if(yes[vert[i]][vert[j]] == 0){
ok = 0;
break;
}
}
}
}
if(ok) ans = max(ans, cnt);
}
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
politicaldevelopment.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main(){
| ^~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i = 0;i < vert.size() && ok; i++){
| ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:50:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int j = 0;j < vert.size(); j++){
| ~~^~~~~~~~~~~~~
# | 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... |