結果
問題 | No.1017 Reiwa Sequence |
ユーザー | やむなく |
提出日時 | 2020-04-03 22:18:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,030 bytes |
コンパイル時間 | 1,886 ms |
コンパイル使用メモリ | 181,264 KB |
実行使用メモリ | 14,416 KB |
最終ジャッジ日時 | 2024-07-03 03:51:42 |
合計ジャッジ時間 | 45,505 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 792 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 10 ms
6,940 KB |
testcase_10 | AC | 33 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 83 ms
6,940 KB |
testcase_13 | AC | 42 ms
6,940 KB |
testcase_14 | AC | 475 ms
6,944 KB |
testcase_15 | AC | 481 ms
6,944 KB |
testcase_16 | AC | 473 ms
6,940 KB |
testcase_17 | AC | 457 ms
6,940 KB |
testcase_18 | AC | 471 ms
6,944 KB |
testcase_19 | AC | 421 ms
6,940 KB |
testcase_20 | AC | 417 ms
6,940 KB |
testcase_21 | AC | 417 ms
6,940 KB |
testcase_22 | AC | 419 ms
6,940 KB |
testcase_23 | AC | 414 ms
6,940 KB |
testcase_24 | AC | 415 ms
6,940 KB |
testcase_25 | AC | 417 ms
6,940 KB |
testcase_26 | AC | 415 ms
6,940 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 27 ms
6,944 KB |
testcase_31 | AC | 3 ms
6,940 KB |
testcase_32 | AC | 123 ms
6,944 KB |
testcase_33 | AC | 99 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 88 ms
6,940 KB |
testcase_38 | AC | 86 ms
6,944 KB |
testcase_39 | AC | 86 ms
6,944 KB |
testcase_40 | AC | 138 ms
10,240 KB |
testcase_41 | AC | 147 ms
10,112 KB |
testcase_42 | AC | 136 ms
9,856 KB |
testcase_43 | AC | 138 ms
10,324 KB |
testcase_44 | AC | 147 ms
10,444 KB |
testcase_45 | AC | 135 ms
10,112 KB |
testcase_46 | AC | 134 ms
9,856 KB |
testcase_47 | AC | 135 ms
9,984 KB |
testcase_48 | AC | 17 ms
6,944 KB |
testcase_49 | AC | 190 ms
14,416 KB |
testcase_50 | AC | 18 ms
6,944 KB |
testcase_51 | AC | 1,658 ms
6,944 KB |
testcase_52 | WA | - |
testcase_53 | WA | - |
ソースコード
// // 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; } vi tmp; int kk = 2e7 / 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){ rep(i, n / 2){ swap(p[xor128() % n], p[xor128() % n]); } 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; }