結果

問題 No.1017 Reiwa Sequence
ユーザー carrot46carrot46
提出日時 2020-04-03 23:13:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,531 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 168,860 KB
実行使用メモリ 36,992 KB
最終ジャッジ日時 2023-09-16 04:32:09
合計ジャッジ時間 13,516 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
35,572 KB
testcase_01 AC 11 ms
35,752 KB
testcase_02 AC 10 ms
35,624 KB
testcase_03 AC 11 ms
35,564 KB
testcase_04 AC 11 ms
35,740 KB
testcase_05 AC 10 ms
35,732 KB
testcase_06 AC 11 ms
35,804 KB
testcase_07 AC 11 ms
35,584 KB
testcase_08 AC 11 ms
35,880 KB
testcase_09 AC 11 ms
35,716 KB
testcase_10 AC 11 ms
35,564 KB
testcase_11 AC 11 ms
35,628 KB
testcase_12 AC 11 ms
35,680 KB
testcase_13 AC 11 ms
35,756 KB
testcase_14 AC 11 ms
35,568 KB
testcase_15 AC 10 ms
35,872 KB
testcase_16 AC 11 ms
35,804 KB
testcase_17 AC 12 ms
35,720 KB
testcase_18 AC 11 ms
35,872 KB
testcase_19 AC 19 ms
35,796 KB
testcase_20 AC 20 ms
35,792 KB
testcase_21 AC 20 ms
35,724 KB
testcase_22 AC 20 ms
35,772 KB
testcase_23 AC 20 ms
35,692 KB
testcase_24 AC 21 ms
35,804 KB
testcase_25 AC 19 ms
35,732 KB
testcase_26 AC 19 ms
35,700 KB
testcase_27 AC 13 ms
35,736 KB
testcase_28 AC 14 ms
35,568 KB
testcase_29 AC 13 ms
35,676 KB
testcase_30 AC 12 ms
35,804 KB
testcase_31 AC 13 ms
35,672 KB
testcase_32 AC 12 ms
35,576 KB
testcase_33 AC 11 ms
35,632 KB
testcase_34 AC 11 ms
35,800 KB
testcase_35 AC 16 ms
35,564 KB
testcase_36 AC 11 ms
35,908 KB
testcase_37 AC 11 ms
35,636 KB
testcase_38 AC 16 ms
35,572 KB
testcase_39 AC 11 ms
35,796 KB
testcase_40 AC 42 ms
36,700 KB
testcase_41 AC 42 ms
36,616 KB
testcase_42 AC 40 ms
36,540 KB
testcase_43 AC 41 ms
36,700 KB
testcase_44 AC 41 ms
36,860 KB
testcase_45 AC 40 ms
36,584 KB
testcase_46 AC 41 ms
36,592 KB
testcase_47 AC 40 ms
36,612 KB
testcase_48 AC 62 ms
36,908 KB
testcase_49 AC 60 ms
36,904 KB
testcase_50 AC 64 ms
36,992 KB
testcase_51 AC 11 ms
35,768 KB
testcase_52 AC 12 ms
35,824 KB
testcase_53 AC 20 ms
35,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int n;
vec mp((1LL<<22), -1);
int ans = -1, pa = -1;
void dfs(int plus, int num, vec &a, int sum){
    if(num == n){
        if(mp[sum] == -1){
            mp[sum] = plus;
        }else{
            pa = plus;
            ans = sum;
        }
    }else if(ans == -1){
        dfs(plus | (1<<num), num + 1, a, sum + a[num]);
        dfs(plus, num + 1, a, sum);
    }
}

int main() {
    cin>>N;
    /*bool det = false;
    if(N >= 14){
        cout<<"Yes"<<endl;
        N = 14;
        det = true;
    }*/
    vec a(N);
    rep(i,N) cin>>a[i];
    n = min(N, 22LL);
    vec k(n);
    rep(i,n) k[i] = a[i];
    dfs(0, 0, k, 0);
    if(ans != -1){
        cout<<"Yes"<<endl;
        rep(i,n){
            int temp = 0;
            if((mp[ans]>>i)&1) temp += a[i];
            if((pa>>i)&1) temp -= a[i];
            cout<<temp;
            i == N - 1 ? cout<<endl : cout<<' ';
        }
        reps(i,n, N){
            cout<<0;
            i == N - 1 ? cout<<endl : cout<<' ';
        }
    }else{
        cout<<"No"<<endl;
    }
}
0