結果

問題 No.1017 Reiwa Sequence
ユーザー やむなくやむなく
提出日時 2020-04-03 22:05:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,985 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 182,832 KB
実行使用メモリ 14,324 KB
最終ジャッジ日時 2023-09-16 01:52:02
合計ジャッジ時間 26,858 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 990 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,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 21 ms
4,376 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 442 ms
4,380 KB
testcase_15 AC 427 ms
4,376 KB
testcase_16 AC 442 ms
4,376 KB
testcase_17 AC 399 ms
4,376 KB
testcase_18 AC 442 ms
4,376 KB
testcase_19 AC 354 ms
4,380 KB
testcase_20 AC 356 ms
4,380 KB
testcase_21 AC 353 ms
4,380 KB
testcase_22 AC 352 ms
4,376 KB
testcase_23 AC 353 ms
4,380 KB
testcase_24 AC 350 ms
4,380 KB
testcase_25 AC 352 ms
4,380 KB
testcase_26 AC 353 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 115 ms
4,376 KB
testcase_32 AC 158 ms
4,376 KB
testcase_33 AC 150 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 168 ms
10,080 KB
testcase_41 AC 168 ms
10,260 KB
testcase_42 AC 166 ms
9,864 KB
testcase_43 AC 165 ms
9,836 KB
testcase_44 AC 171 ms
10,232 KB
testcase_45 AC 170 ms
10,188 KB
testcase_46 AC 168 ms
9,936 KB
testcase_47 AC 166 ms
9,900 KB
testcase_48 AC 16 ms
6,592 KB
testcase_49 AC 211 ms
14,324 KB
testcase_50 AC 16 ms
6,668 KB
testcase_51 TLE -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// Created by yamunaku on 2020/04/03.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

unsigned long long xor128(){
    static unsigned long long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long long t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

int main(){
    //CFS;
    int n;
    cin >> n;
    map<int, int> mp;
    vi a(n);
    vector<pair<ll, int>> p(n);
    rep(i, n){
        cin >> a[i];
        p[i] = {a[i], i};
        auto itr = mp.find(a[i]);
        if(itr != mp.end()){
            CYES;
            vi ans(n, 0);
            ans[i] = a[i], ans[itr->second] = -a[i];
            rep(j, n){
                cout << ans[j] << " ";
            }
            cout << endl;
            return 0;
        }
        mp[a[i]] = i;
    }
    sort(all(p), greater<pair<ll, int>>());
    vi tmp;
    int kk = 3e7/n;
    rep(t, kk){
        ll sum = 0;
        tmp = vi(n, 0);
        bool ok = false;
        rep(i, n){
            tmp[i] = xor128() % 3 - 1;
            if(tmp[i] != 0) ok = true;
            sum += tmp[i] * p[i].first;
        }
        if(ok) if(sum == 0) goto next;
    }
    rep(t, kk){
        ll sum = 0;
        tmp = vi(n, 0);
        repl(i, xor128()%n, n){
            if(sum > 0){
                if(sum - p[i].first == 0){
                    tmp[i] = -1;
                    goto next;
                }else{
                    if(xor128() % 2){
                        tmp[i] = -1;
                        sum -= p[i].first;
                    }
                }
            }else{
                if(sum + p[i].first == 0){
                    tmp[i] = 1;
                    goto next;
                }else{
                    if(xor128() % 2){
                        tmp[i] = 1;
                        sum += p[i].first;
                    }
                }
            }
        }
    }
    CNO;
    return 0;
    next:;
    CYES;
    vi ans(n, 0);
    rep(i, n){
        ans[p[i].second] = tmp[i] * p[i].first;
    }
    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}
0