#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
using namespace std;
int n = 0;
int m = 0;
vector <vector<int>> buyuler;
set <vector<int>> st;
inline void dp(int ind, vector <bool> dizi, vector <int> used_buyuler){
bool flag = true;
for(bool temp : dizi){
if(temp == false){
flag = false;
break;
}
}
if(flag == true){
st.insert(used_buyuler);
// cout << "eklendi ";
// for(int fgh : used_buyuler){
// cout << fgh + 1 << " ";
// }
// cout << endl;
return ;
}
if(ind >= m){
return ;
}
dp(ind + 1, dizi, used_buyuler);
for(int tmp : buyuler[ind]){
dizi[tmp - 1] = !dizi[tmp - 1];
}
// cout << ind + 1 << ". buyu kullanildiktan sonraki kart durumlari : ";
// for(int i = 0; i < n; i++){
// cout << dizi[i] << " ";
// }
// cout << endl;
used_buyuler.push_back(ind);
dp(ind + 1, dizi, used_buyuler);
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
cin >> n >> m;
buyuler.resize(m);
for(int i = 0; i < m; i++){
int k = 0;
cin >> k;
for(int j = 0; j < k; j++){
int tmp = 0;
cin >> tmp;
buyuler[i].push_back(tmp);
}
}
vector <bool> dizim;
dizim.assign(n, false);
vector <int> tempv;
dp(0, dizim, tempv);
vector <int> cevap = *st.begin();
cout << cevap.size() << endl;
for(int tmp : cevap){
cout << tmp + 1 << " ";
}
cout << endl;
}
| # | 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... |