結果

問題 No.1017 Reiwa Sequence
ユーザー ngtkanangtkana
提出日時 2020-04-03 23:19:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 208,924 KB
実行使用メモリ 36,744 KB
最終ジャッジ日時 2023-09-16 04:51:27
合計ジャッジ時間 21,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 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,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 551 ms
36,312 KB
testcase_20 AC 588 ms
36,068 KB
testcase_21 AC 583 ms
36,068 KB
testcase_22 AC 556 ms
36,124 KB
testcase_23 AC 447 ms
36,376 KB
testcase_24 AC 449 ms
36,176 KB
testcase_25 AC 395 ms
36,088 KB
testcase_26 AC 316 ms
36,136 KB
testcase_27 AC 332 ms
24,476 KB
testcase_28 AC 409 ms
28,136 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 12 ms
5,088 KB
testcase_31 AC 36 ms
7,644 KB
testcase_32 AC 172 ms
19,808 KB
testcase_33 AC 5 ms
4,380 KB
testcase_34 AC 160 ms
19,680 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 191 ms
20,016 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 202 ms
19,700 KB
testcase_40 AC 525 ms
36,624 KB
testcase_41 AC 478 ms
36,584 KB
testcase_42 AC 512 ms
36,616 KB
testcase_43 AC 486 ms
36,536 KB
testcase_44 AC 16 ms
4,380 KB
testcase_45 AC 471 ms
36,620 KB
testcase_46 AC 401 ms
36,484 KB
testcase_47 AC 326 ms
36,744 KB
testcase_48 AC 27 ms
4,412 KB
testcase_49 AC 25 ms
4,380 KB
testcase_50 AC 26 ms
4,500 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 474 ms
35,844 KB
testcase_53 AC 74 ms
11,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint m=std::min(n,23ll);
    lint M=1ll<<m;
    std::map<lint,lint>map;
    lint bs0=-1,bs1=-1;
    for(lint bs=0;bs<M;bs++){
        lint now=0;
        for(lint i=0;i<m;i++){
            if(!(bs>>i&1))continue;
            now+=a.at(i);
        }
        auto found=map.find(now);
        if(found!=map.end()){
            bs0=found->second;
            bs1=bs;
            break;
        }
        map.emplace(now,bs);
    }
    if(bs0==-1){
        std::cout<<"No"<<'\n';
        return 0;
    }
    std::cout<<"Yes"<<'\n';
    lint an=bs0^bs1;
    bs0^=an,bs1^=an;
    for(lint i=0;i<n;i++){
        lint sign=m<=i?0:bs0>>i&1?+1:bs1>>i&1?-1:0;
        std::cout<<(i?" ":"")<<sign*a.at(i);
    }
    std::cout<<'\n';
}
0