답안 #879324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879324 2023-11-27T06:54:43 Z dilshod9890 Bootfall (IZhO17_bootfall) C++17
6 / 100
1000 ms 66380 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

int n;
vector<int> a;

void rec(vector<int> b, int i, vector<int>& c) {
    if (i == a.size()) {
        c.push_back(abs(accumulate(a.begin(), a.end(), 0) - 2 * accumulate(b.begin(), b.end(), 0)));
        return;
    }

    b.push_back(a[i]);
    rec(b, i + 1, c);

    b.pop_back();
    rec(b, i + 1, c);
}




int main() {
    cin >> n;
    a.resize(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> c;

    for (int i = 0; i < n; ++i) {
        rec({}, 0, c);
    }

    if (*min_element(c.begin(), c.end()) != 0) {
        cout << 0 << endl;
    } else {
        c.clear();
        vector<set<int>> g;

        for (int i = 0; i < n; ++i) {
            int d = a[i];
            a.erase(a.begin() + i);
            rec({}, 0, c);
            a.insert(a.begin() + i, d);
            sort(c.begin(), c.end());
            g.push_back(set<int>(c.begin(), c.end()));
            c.clear();
        }

        set<int> c_set = g[0];

        for (const auto& i : g) {
            set<int> intersection_result;
            set_intersection(c_set.begin(), c_set.end(), i.begin(), i.end(), inserter(intersection_result, intersection_result.begin()));
            c_set = intersection_result;
        }

        vector<int> c_vector(c_set.begin(), c_set.end());
        sort(c_vector.begin(), c_vector.end());

        cout << c_vector.size() << endl;

        for (int i : c_vector) {
            cout << i << " ";
        }

        cout << endl;
    }

    return 0;
}

Compilation message

bootfall.cpp: In function 'void rec(std::vector<int>, int, std::vector<int>&)':
bootfall.cpp:13:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     if (i == a.size()) {
      |         ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Execution timed out 1061 ms 66380 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Execution timed out 1061 ms 66380 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Execution timed out 1061 ms 66380 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Execution timed out 1061 ms 66380 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 776 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 728 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Execution timed out 1061 ms 66380 KB Time limit exceeded
11 Halted 0 ms 0 KB -