結果

問題 No.1017 Reiwa Sequence
ユーザー hedwig100hedwig100
提出日時 2020-04-05 18:22:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,111 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 170,404 KB
実行使用メモリ 129,456 KB
最終ジャッジ日時 2023-09-16 06:49:20
合計ジャッジ時間 28,165 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
80,188 KB
testcase_01 AC 40 ms
80,560 KB
testcase_02 AC 32 ms
80,360 KB
testcase_03 AC 32 ms
80,312 KB
testcase_04 AC 32 ms
80,308 KB
testcase_05 AC 32 ms
80,184 KB
testcase_06 AC 32 ms
80,344 KB
testcase_07 AC 32 ms
80,396 KB
testcase_08 AC 32 ms
80,536 KB
testcase_09 AC 33 ms
80,572 KB
testcase_10 AC 168 ms
91,020 KB
testcase_11 AC 32 ms
80,560 KB
testcase_12 AC 1,039 ms
121,400 KB
testcase_13 AC 1,019 ms
121,276 KB
testcase_14 AC 40 ms
80,584 KB
testcase_15 AC 40 ms
80,580 KB
testcase_16 AC 39 ms
80,568 KB
testcase_17 AC 42 ms
80,820 KB
testcase_18 AC 39 ms
80,376 KB
testcase_19 AC 180 ms
96,564 KB
testcase_20 AC 186 ms
96,488 KB
testcase_21 AC 185 ms
96,536 KB
testcase_22 AC 195 ms
96,932 KB
testcase_23 AC 179 ms
96,728 KB
testcase_24 AC 179 ms
96,796 KB
testcase_25 AC 166 ms
96,568 KB
testcase_26 AC 160 ms
96,568 KB
testcase_27 AC 184 ms
96,668 KB
testcase_28 AC 173 ms
96,848 KB
testcase_29 AC 178 ms
96,700 KB
testcase_30 AC 173 ms
96,228 KB
testcase_31 AC 172 ms
95,488 KB
testcase_32 AC 164 ms
94,876 KB
testcase_33 AC 148 ms
92,772 KB
testcase_34 AC 164 ms
92,704 KB
testcase_35 AC 115 ms
92,524 KB
testcase_36 AC 153 ms
92,700 KB
testcase_37 AC 169 ms
94,832 KB
testcase_38 AC 150 ms
94,504 KB
testcase_39 AC 168 ms
94,816 KB
testcase_40 AC 1,110 ms
127,904 KB
testcase_41 AC 1,074 ms
127,236 KB
testcase_42 AC 1,111 ms
129,456 KB
testcase_43 AC 1,077 ms
127,952 KB
testcase_44 AC 360 ms
101,244 KB
testcase_45 AC 1,081 ms
126,188 KB
testcase_46 AC 941 ms
125,864 KB
testcase_47 AC 773 ms
123,100 KB
testcase_48 AC 1,023 ms
119,900 KB
testcase_49 AC 376 ms
99,100 KB
testcase_50 AC 380 ms
103,856 KB
testcase_51 AC 39 ms
80,716 KB
testcase_52 AC 168 ms
96,972 KB
testcase_53 AC 152 ms
96,928 KB
権限があれば一括ダウンロードができます

ソースコード

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(k);
    rep(i,k) cin >> a[i];
    
    vector<vector<int>> tot(3300005);
    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 < 3300005; 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