diff --git "a/5\354\233\2249\354\235\274/11578/11578_cpp_\352\271\200\354\206\214\355\235\254.cpp" "b/5\354\233\2249\354\235\274/11578/11578_cpp_\352\271\200\354\206\214\355\235\254.cpp" new file mode 100644 index 0000000..8cf37ba --- /dev/null +++ "b/5\354\233\2249\354\235\274/11578/11578_cpp_\352\271\200\354\206\214\355\235\254.cpp" @@ -0,0 +1,51 @@ +#include "bits/stdc++.h" + +using namespace std; +//11578, 14497, 15976, 1953, 20313, 20955, 24391, 5859 +vector can_solve[11]; //index¹ø ÇлýÀÌ Ç® ¼ö ÀÖ´Â ¹®Á¦ +vector team; +int problem, people, val, num, result = 11; + +void dfs(int cnt, int idx) { //Æ÷ÇÔÇÑ »ç¶÷ ¼ö, ÀÌÈÄ »ç¶÷ + if (cnt >= result) return; //ÇöÀç ÀúÀåµÈ °ªº¸´Ù ¸¹Àº ¼öÀÇ »ç¶÷ÀÌ ÇÊ¿äÇÑ °æ¿ì return + if (cnt > 0) { + bool solved[11] = { false, }; + for (int i = 0; i < cnt; i++) { + int cidx = team[i]; + //ÇöÀç ÆÀÀ¸·Î Ç® ¼ö ÀÖ´Â ¹®Á¦ °Ë»ç + for (int j = 0; j < can_solve[cidx].size(); j++) + solved[can_solve[cidx][j]] = true; + } + bool avail = true; + for (int i = 1; i <= problem; i++) { + if (!solved[i]) { + avail = false; + break; + } + } + //¸ðµç ¹®Á¦¸¦ Ç® ¼ö ÀÖ´Ù¸é ÃÖ¼Ò ÆÀ¿ø °»½Å + if (avail) + result = min(result, cnt); + } + if (idx > people) return; + for (int i = idx; i <= people; i++) { + team.push_back(i); + dfs(cnt + 1, i + 1); + team.pop_back(); + } +} + +int main() { + cin >> problem >> people; + for (int i = 1; i <= people; i++) { + cin >> val; + for (int j = 0; j < val; j++) { + cin >> num; + can_solve[i].push_back(num); + } + } + dfs(0, 1); + if (result == 11) result = -1; + cout << result; + return 0; +} \ No newline at end of file diff --git "a/5\354\233\2249\354\235\274/1953/1953_cpp_\352\271\200\354\206\214\355\235\254.cpp" "b/5\354\233\2249\354\235\274/1953/1953_cpp_\352\271\200\354\206\214\355\235\254.cpp" new file mode 100644 index 0000000..2330cc0 --- /dev/null +++ "b/5\354\233\2249\354\235\274/1953/1953_cpp_\352\271\200\354\206\214\355\235\254.cpp" @@ -0,0 +1,71 @@ +#include "bits/stdc++.h" + +using namespace std; +// 14497, 15976, 1953, 20313, 20955, 24391, 5859 +int n; +vector blue, white; + + + +int main() { + ios::sync_with_stdio(false); + cin.tie(0); + cin >> n; + for (int i = 1; i <= n; i++) + { + int cnt; + cin >> cnt; + if (i == 1) { + blue.push_back(i); + for (int j = 0; j < cnt; j++) + { + int s; + cin >> s; + } + } + else { + int sum = 0; + for (int j = 0; j < cnt; j++) + { + int hate; + cin >> hate; + auto it1 = find(blue.begin(), blue.end(), hate); + auto it2 = find(white.begin(), white.end(), hate); + + if (it1 == blue.end()&&sum==0) { + blue.push_back(i); + sum++; + } + if (it2 == white.end()&&sum==0) { + white.push_back(i); + sum++; + } + if(sum==0) + blue.push_back(i); + + + } + } + } + + sort(blue.begin(), blue.end()); + sort(white.begin(), white.end()); + if (white.size() == 0) { + blue.erase(blue.begin() + 1); + white.push_back(1); + }if (blue.size() == 0) { + white.erase(white.begin() + 1); + blue.push_back(1); + } + cout << blue.size() << endl; + for (int i = 0; i < blue.size(); i++) + { + cout << blue.at(i) << " "; + } + cout << endl << white.size() << endl; + for (int i = 0; i < white.size(); i++) + { + cout << white.at(i) << " "; + } + +} \ No newline at end of file