結果

問題 No.1017 Reiwa Sequence
ユーザー minatominato
提出日時 2020-04-19 19:31:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 1,455 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 184,968 KB
実行使用メモリ 28,592 KB
最終ジャッジ日時 2023-09-16 07:22:30
合計ジャッジ時間 20,381 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 416 ms
27,980 KB
testcase_20 AC 468 ms
28,060 KB
testcase_21 AC 465 ms
27,940 KB
testcase_22 AC 429 ms
27,972 KB
testcase_23 AC 379 ms
27,912 KB
testcase_24 AC 362 ms
27,932 KB
testcase_25 AC 323 ms
27,924 KB
testcase_26 AC 259 ms
28,244 KB
testcase_27 AC 248 ms
19,260 KB
testcase_28 AC 325 ms
21,996 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 10 ms
4,528 KB
testcase_31 AC 28 ms
6,436 KB
testcase_32 AC 138 ms
15,652 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 133 ms
15,720 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 154 ms
15,640 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 165 ms
15,856 KB
testcase_40 AC 478 ms
28,512 KB
testcase_41 AC 416 ms
28,436 KB
testcase_42 AC 437 ms
28,384 KB
testcase_43 AC 433 ms
28,424 KB
testcase_44 AC 16 ms
4,376 KB
testcase_45 AC 410 ms
28,592 KB
testcase_46 AC 366 ms
28,352 KB
testcase_47 AC 269 ms
28,336 KB
testcase_48 AC 26 ms
4,380 KB
testcase_49 AC 24 ms
4,564 KB
testcase_50 AC 26 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 342 ms
27,752 KB
testcase_53 AC 60 ms
9,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int M = min(N,22);
    vector<int> ans(N);
    map<int, int> dic;
    for (int mask = 1; mask < (1<<M); mask++) {
        int val = 0;
        rep(i,M) {
            if (mask&(1<<i)) val += A[i];
        }
        if (dic.count(val)) {
            int num = dic[val];
            rep(i,M) {
                if (mask&(1<<i)) ans[i] = A[i];
                if (num&(1<<i)) ans[i] = -A[i];
            }
            cout << "Yes" << ln;
            for (auto i : ans) cout << i << " ";
            cout << ln;
            return 0;
        } else dic.emplace(val,mask);
    }

    cout << "No" << ln;
}
0