結果

問題 No.1017 Reiwa Sequence
ユーザー carrot46carrot46
提出日時 2020-04-03 23:11:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,543 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 168,836 KB
実行使用メモリ 36,880 KB
最終ジャッジ日時 2023-09-16 04:30:18
合計ジャッジ時間 16,347 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
35,644 KB
testcase_01 RE -
testcase_02 AC 11 ms
35,544 KB
testcase_03 AC 11 ms
35,648 KB
testcase_04 AC 11 ms
35,796 KB
testcase_05 AC 11 ms
35,728 KB
testcase_06 AC 11 ms
35,796 KB
testcase_07 AC 10 ms
35,680 KB
testcase_08 AC 11 ms
35,724 KB
testcase_09 AC 11 ms
35,784 KB
testcase_10 AC 11 ms
35,704 KB
testcase_11 AC 11 ms
35,736 KB
testcase_12 AC 11 ms
35,772 KB
testcase_13 AC 11 ms
35,520 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 14 ms
35,560 KB
testcase_28 AC 14 ms
35,744 KB
testcase_29 AC 13 ms
35,768 KB
testcase_30 AC 12 ms
35,672 KB
testcase_31 AC 12 ms
35,568 KB
testcase_32 AC 11 ms
35,636 KB
testcase_33 AC 11 ms
35,560 KB
testcase_34 AC 10 ms
35,736 KB
testcase_35 AC 16 ms
35,784 KB
testcase_36 AC 11 ms
35,536 KB
testcase_37 AC 10 ms
35,580 KB
testcase_38 AC 16 ms
35,684 KB
testcase_39 AC 12 ms
35,800 KB
testcase_40 AC 42 ms
36,552 KB
testcase_41 AC 42 ms
36,428 KB
testcase_42 AC 39 ms
36,592 KB
testcase_43 AC 41 ms
36,708 KB
testcase_44 AC 41 ms
36,504 KB
testcase_45 AC 42 ms
36,636 KB
testcase_46 AC 40 ms
36,544 KB
testcase_47 AC 41 ms
36,692 KB
testcase_48 AC 59 ms
36,860 KB
testcase_49 AC 60 ms
36,880 KB
testcase_50 AC 63 ms
36,856 KB
testcase_51 RE -
testcase_52 AC 13 ms
35,860 KB
testcase_53 AC 20 ms
35,792 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 && sum != 0){
        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