답안 #842024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842024 2023-09-02T10:18:50 Z Elvin_Fritl Bootfall (IZhO17_bootfall) C++17
0 / 100
40 ms 348 KB
#include <string>
#include <bits/functexcept.h>
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#include <bits/functional_hash.h>

#pragma push_macro("__SIZEOF_LONG__")
#pragma push_macro("__cplusplus")
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
#define unsigned unsigned long
#define __cplusplus 201102L

#define __builtin_popcountl __builtin_popcountll
#define __builtin_ctzl __builtin_ctzll

#include <bitset>

#pragma pop_macro("__cplusplus")
#pragma pop_macro("__SIZEOF_LONG__")
#undef unsigned
#undef __builtin_popcountl
#undef __builtin_ctzl

#include <bits/stdc++.h>
using namespace std;

const int N = 505 , inf = 1e9 + 199;

int32_t main()
{
    int n;
    cin>>n;
    int a[n],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    vector<int>res;
    for(int x=1;x<2000;x++){
        bool as = true;
        for(int k=0;k<n;k++){
            vector<int>v;
            for(int i=0;i<n;i++){
                if(i == k){
                    continue;
                }
                v.push_back(a[i]);
            }
            int eded = (sum - a[k] + x);
            if(eded%2 != 0){
                as=false;
                break;
            }
            eded/=2;
            v.push_back(x);
            bitset<N*N> dp;
            dp[0] = true;
            for(auto &ii:v){
                dp |= (dp << ii);
            }
            if(dp[eded] == true){
                continue;
            }
            as=false;
            break;
            dp.reset();
        }
        if(as == true){
            res.push_back(x);
        }
    }
    cout<<res.size()<<endl;
    for(auto &i:res){
        cout<<i<<" ";
    }


}

/*



*/

Compilation message

bootfall.cpp:9: warning: "__SIZEOF_LONG__" redefined
    9 | #define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
      | 
<built-in>: note: this is the location of the previous definition
bootfall.cpp:11: warning: "__cplusplus" redefined
   11 | #define __cplusplus 201102L
      | 
<built-in>: note: this is the location of the previous definition
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 348 KB Output is correct
2 Correct 40 ms 348 KB Output is correct
3 Incorrect 20 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -