結果

問題 No.1017 Reiwa Sequence
ユーザー hedwig100hedwig100
提出日時 2020-04-05 18:18:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 170,388 KB
実行使用メモリ 28,980 KB
最終ジャッジ日時 2023-09-16 06:47:10
合計ジャッジ時間 19,912 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,812 KB
testcase_01 AC 6 ms
10,748 KB
testcase_02 AC 6 ms
10,800 KB
testcase_03 AC 5 ms
10,680 KB
testcase_04 AC 5 ms
10,768 KB
testcase_05 AC 5 ms
10,808 KB
testcase_06 AC 6 ms
10,760 KB
testcase_07 AC 5 ms
10,704 KB
testcase_08 AC 6 ms
10,812 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
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 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 AC 378 ms
28,980 KB
testcase_50 RE -
testcase_51 AC 6 ms
10,756 KB
testcase_52 RE -
testcase_53 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll MOD = 1e9 + 7;
const ll INF = 1e10;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

int main() {
    int k; cin >> k;
    int n = min(22,k);
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    vector<vector<int>> tot(330005);
    for (int bit = 0;bit < (1 << n); bit ++ ) {
        int tmp = 0;
        rep(i,n) {
            if ((bit>>i)&1) {
                tmp += a[i];
            }
        }
        tot[tmp].push_back(bit);
    }

    int p = 0,m = 0;
    for (int i = 1; i < 330005; i++) {
        if (tot[i].size() > 1) {
            p = tot[i][0];
            m = tot[i][1];
            break;
        }
    }

    if (p == 0) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < n; i ++) {
        if ((p>>i)&1 && (m>>i)&1) a[i] = 0;
        else if ((p>>i)&1) continue;
        else if ((m>>i)&1) a[i] = -a[i];
        else a[i] = 0;
    }
    
    cout << "Yes" << endl;
    rep(i,n) cout << a[i] << ' ';
    rep(i,max(k - n,0)) cout << 0 << ' ';
    cout << '\n';
}
0