結果

問題 No.1017 Reiwa Sequence
ユーザー milanis48663220milanis48663220
提出日時 2020-11-23 23:11:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,477 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 96,296 KB
実行使用メモリ 19,392 KB
最終ジャッジ日時 2023-10-01 00:29:02
合計ジャッジ時間 13,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 6 ms
18,616 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 6 ms
18,664 KB
testcase_15 AC 6 ms
18,636 KB
testcase_16 AC 6 ms
18,708 KB
testcase_17 AC 7 ms
18,640 KB
testcase_18 AC 7 ms
18,664 KB
testcase_19 AC 49 ms
18,668 KB
testcase_20 AC 49 ms
18,700 KB
testcase_21 AC 50 ms
18,616 KB
testcase_22 AC 50 ms
18,668 KB
testcase_23 AC 50 ms
18,644 KB
testcase_24 AC 49 ms
18,616 KB
testcase_25 AC 49 ms
18,688 KB
testcase_26 AC 49 ms
18,748 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 6 ms
18,620 KB
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int m = min(22, n);
    vector<int> idx(4e6, -1);
    for(int i = 1; i < (1<<m); i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            if(i&(1<<j)) sum += a[j];
        }
        if(idx[sum] != -1){
            int x = i-(i&idx[sum]);
            int y = idx[sum]-(i&idx[sum]);
            for(int j = 0; j < m; j++){
                cout << "Yes" << endl;
                if(x&(1<<j)) cout << a[j] << ' ';
                else if(y&(1<<j)) cout << -a[j] << ' ';
                else cout << "0 ";
            }
            for(int j = m; j < n; j++) cout << "0 ";
            cout << endl;
            return 0;
        }else{
            idx[sum] = i;
        }
    }
    cout << "No" << endl;
}
0