結果

問題 No.1017 Reiwa Sequence
ユーザー minatominato
提出日時 2020-05-25 08:31:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 1,455 bytes
コンパイル時間 2,530 ms
コンパイル使用メモリ 219,000 KB
実行使用メモリ 28,448 KB
最終ジャッジ日時 2023-09-16 08:49:18
合計ジャッジ時間 18,977 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 338 ms
27,916 KB
testcase_20 AC 374 ms
27,924 KB
testcase_21 AC 375 ms
28,028 KB
testcase_22 AC 360 ms
27,984 KB
testcase_23 AC 316 ms
28,028 KB
testcase_24 AC 310 ms
28,024 KB
testcase_25 AC 291 ms
27,888 KB
testcase_26 AC 266 ms
27,980 KB
testcase_27 AC 212 ms
19,156 KB
testcase_28 AC 262 ms
21,936 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 11 ms
4,536 KB
testcase_31 AC 30 ms
6,528 KB
testcase_32 AC 135 ms
15,652 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 122 ms
15,728 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 133 ms
15,636 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 148 ms
15,568 KB
testcase_40 AC 383 ms
28,376 KB
testcase_41 AC 348 ms
28,392 KB
testcase_42 AC 381 ms
28,264 KB
testcase_43 AC 357 ms
28,268 KB
testcase_44 AC 16 ms
4,380 KB
testcase_45 AC 351 ms
28,448 KB
testcase_46 AC 321 ms
28,392 KB
testcase_47 AC 269 ms
28,268 KB
testcase_48 AC 26 ms
4,380 KB
testcase_49 AC 24 ms
4,388 KB
testcase_50 AC 24 ms
4,428 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 301 ms
27,648 KB
testcase_53 AC 61 ms
9,560 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