結果

問題 No.1017 Reiwa Sequence
ユーザー hiikunZhiikunZ
提出日時 2021-07-18 12:31:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,263 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 208,728 KB
実行使用メモリ 36,780 KB
最終ジャッジ日時 2023-09-22 14:22:59
合計ジャッジ時間 16,965 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
34,312 KB
testcase_01 AC 11 ms
34,364 KB
testcase_02 AC 11 ms
34,344 KB
testcase_03 AC 10 ms
34,364 KB
testcase_04 AC 11 ms
34,308 KB
testcase_05 AC 11 ms
34,308 KB
testcase_06 AC 11 ms
34,252 KB
testcase_07 AC 11 ms
34,524 KB
testcase_08 AC 11 ms
34,416 KB
testcase_09 AC 12 ms
34,344 KB
testcase_10 AC 12 ms
34,260 KB
testcase_11 AC 11 ms
34,364 KB
testcase_12 AC 11 ms
34,296 KB
testcase_13 AC 11 ms
34,348 KB
testcase_14 AC 11 ms
34,476 KB
testcase_15 AC 12 ms
34,200 KB
testcase_16 AC 11 ms
34,320 KB
testcase_17 AC 12 ms
34,344 KB
testcase_18 AC 11 ms
34,192 KB
testcase_19 AC 53 ms
34,200 KB
testcase_20 AC 52 ms
34,244 KB
testcase_21 AC 53 ms
34,248 KB
testcase_22 AC 53 ms
34,244 KB
testcase_23 AC 52 ms
34,352 KB
testcase_24 AC 52 ms
34,400 KB
testcase_25 AC 51 ms
34,344 KB
testcase_26 AC 53 ms
34,244 KB
testcase_27 AC 38 ms
34,408 KB
testcase_28 AC 43 ms
34,312 KB
testcase_29 AC 12 ms
34,268 KB
testcase_30 AC 13 ms
34,304 KB
testcase_31 AC 17 ms
34,252 KB
testcase_32 AC 32 ms
34,500 KB
testcase_33 AC 12 ms
34,236 KB
testcase_34 AC 32 ms
34,412 KB
testcase_35 AC 11 ms
34,360 KB
testcase_36 AC 11 ms
34,416 KB
testcase_37 AC 33 ms
34,244 KB
testcase_38 AC 11 ms
34,360 KB
testcase_39 AC 32 ms
34,176 KB
testcase_40 AC 90 ms
35,584 KB
testcase_41 AC 89 ms
35,508 KB
testcase_42 AC 89 ms
35,736 KB
testcase_43 AC 90 ms
35,584 KB
testcase_44 AC 42 ms
35,632 KB
testcase_45 AC 89 ms
35,692 KB
testcase_46 AC 88 ms
35,736 KB
testcase_47 AC 88 ms
35,668 KB
testcase_48 AC 61 ms
36,620 KB
testcase_49 AC 61 ms
36,748 KB
testcase_50 AC 65 ms
36,780 KB
testcase_51 AC 12 ms
34,404 KB
testcase_52 AC 52 ms
34,408 KB
testcase_53 AC 20 ms
34,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <atcoder/twosat>
using namespace std;
using namespace atcoder;
using ll = long long int;
using ld = long double;
const ll MAX = 5000000000000000000;
const ld PI = 3.14159265358979;
const ll MOD = 0;//2024948111;
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
mt19937 mt;
void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0;i < N;i++) cin >> A[i];
    ll n = min(25LL,N);
    vector<ll> memo(4000000,-1);
    ll ans1 = -1,ans2 = -1;
    for(ll bit = 0;bit < (1LL << n);bit++){
        ll p = 0;
        for(ll i = 0;i < n;i++){
            if(bit & (1LL << i)) p += A[i];
        }
        if(memo[p] != -1){
            ans1 = memo[p];
            ans2 = bit;
            break;
        }
        memo[p] = bit;
    }
    if(ans1 == -1) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        vector<ll> B(N,0);
        ll s = 0;
        for(ll i = 0;i < n;i++){
            if(ans1 & (1LL << i)) B[i] += A[i];
            if(ans2 & (1LL << i)) B[i] -= A[i];
            s += B[i];
        }
        for(ll i = 0;i < N - 1;i++) cout << B[i] << ' ';
        cout << B[N - 1] << endl;
    }
}
0