답안 #95968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95968 2019-02-04T19:28:07 Z alextodoran Norela (info1cup18_norela) C++14
100 / 100
132 ms 376 KB
#include <bits/stdc++.h>

#define MM 26
#define ll long long

using namespace std;

int n, m;

ll spell[MM];

vector <int> ans;

vector <int> v;

int mi = -1;

void bk(int pos, ll mk)
{
    if(pos == m + 1)
    {
        if(mk == (1LL << n) - 1)
            if(v.size() <= mi || mi == -1)
            {
                mi = v.size();
                ans = v;
            }
        return;
    }
    bk(pos + 1, mk);
    v.push_back(pos);
    bk(pos + 1, mk ^ spell[pos]);
    v.pop_back();
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int l;
        cin >> l;
        for(int j = 1; j <= l; j++)
        {
            int e;
            cin >> e;
            spell[i] |= (1LL << (e - 1));
        }
    }
    bk(1, 0);
    cout << mi << "\n";
    for(auto i : ans)
        cout << i << " ";
    cout << "\n";
    return 0;
}

Compilation message

norela.cpp: In function 'void bk(int, long long int)':
norela.cpp:23:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(v.size() <= mi || mi == -1)
                ~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
8 Correct 18 ms 256 KB Output is correct
9 Correct 18 ms 256 KB Output is correct
10 Correct 18 ms 256 KB Output is correct
11 Correct 18 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
8 Correct 18 ms 256 KB Output is correct
9 Correct 18 ms 256 KB Output is correct
10 Correct 18 ms 256 KB Output is correct
11 Correct 18 ms 256 KB Output is correct
12 Correct 30 ms 376 KB Output is correct
13 Correct 33 ms 376 KB Output is correct
14 Correct 33 ms 376 KB Output is correct
15 Correct 34 ms 376 KB Output is correct
16 Correct 34 ms 256 KB Output is correct
17 Correct 34 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
8 Correct 18 ms 256 KB Output is correct
9 Correct 18 ms 256 KB Output is correct
10 Correct 18 ms 256 KB Output is correct
11 Correct 18 ms 256 KB Output is correct
12 Correct 30 ms 376 KB Output is correct
13 Correct 33 ms 376 KB Output is correct
14 Correct 33 ms 376 KB Output is correct
15 Correct 34 ms 376 KB Output is correct
16 Correct 34 ms 256 KB Output is correct
17 Correct 34 ms 256 KB Output is correct
18 Correct 65 ms 376 KB Output is correct
19 Correct 65 ms 356 KB Output is correct
20 Correct 128 ms 256 KB Output is correct
21 Correct 129 ms 308 KB Output is correct
22 Correct 132 ms 356 KB Output is correct
23 Correct 128 ms 256 KB Output is correct