結果

問題 No.1017 Reiwa Sequence
ユーザー carrot46carrot46
提出日時 2020-04-03 22:56:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,603 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 168,484 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-16 04:07:03
合計ジャッジ時間 12,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 22 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 22 ms
4,376 KB
testcase_20 AC 22 ms
4,384 KB
testcase_21 AC 22 ms
4,380 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 22 ms
4,380 KB
testcase_24 AC 22 ms
4,376 KB
testcase_25 AC 22 ms
4,376 KB
testcase_26 AC 22 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 4 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 22 ms
4,380 KB
testcase_37 WA -
testcase_38 AC 5 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 33 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 53 ms
4,380 KB
testcase_49 AC 52 ms
4,384 KB
testcase_50 AC 55 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

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 ansp = -1, ansm = -1, n;
bool solve = false;
void dfs(int plus, int minus, int num, vec &a, int sum){
    if(num == n){
        if(sum == 0 && (plus != 0 || minus != 0)){
            ansp = plus;
            ansm = minus;
            solve = true;
        }
    }else if(!solve){
        dfs(plus | (1<<num), minus, num + 1, a, sum + a[num]);
        dfs(plus, minus | (1<<num), num + 1, a, sum - a[num]);
        dfs(plus, minus, 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, 14LL);
    vec k(n);
    rep(i,n) k[i] = a[i];
    dfs(0, 0, 0, k, 0);
    if(solve){
        cout<<"Yes"<<endl;
        rep(i,n) {
            if((ansp>>i)&1) cout<<a[i];
            else if((ansm>>i)&1) cout<<-a[i];
            else cout<<0;
            i == N - 1 ? cout<<endl : cout<<' ';
        }
        reps(i, n, N) {
            cout<<0;
            i == N - 1 ? cout<<endl : cout<<' ';
        }
    }else{
        cout<<"No"<<endl;
    }
}
0