結果
問題 | No.1017 Reiwa Sequence |
ユーザー | やむなく |
提出日時 | 2020-04-03 22:26:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
J_TLE
(最初)
|
実行時間 | - |
コード長 | 3,718 bytes |
コンパイル時間 | 2,103 ms |
コンパイル使用メモリ | 184,268 KB |
実行使用メモリ | 13,824 KB |
最終ジャッジ日時 | 2024-07-03 04:27:50 |
合計ジャッジ時間 | 35,546 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 373 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 9 ms
5,376 KB |
testcase_10 | AC | 30 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 43 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 227 ms
5,376 KB |
testcase_15 | AC | 230 ms
5,376 KB |
testcase_16 | AC | 230 ms
5,376 KB |
testcase_17 | AC | 231 ms
5,376 KB |
testcase_18 | AC | 235 ms
5,376 KB |
testcase_19 | AC | 204 ms
5,376 KB |
testcase_20 | AC | 201 ms
5,376 KB |
testcase_21 | AC | 203 ms
5,376 KB |
testcase_22 | AC | 204 ms
5,376 KB |
testcase_23 | AC | 204 ms
5,376 KB |
testcase_24 | AC | 201 ms
5,376 KB |
testcase_25 | AC | 199 ms
5,376 KB |
testcase_26 | AC | 196 ms
5,376 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 26 ms
5,376 KB |
testcase_31 | AC | 3 ms
5,376 KB |
testcase_32 | AC | 101 ms
5,376 KB |
testcase_33 | AC | 51 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 68 ms
9,856 KB |
testcase_41 | AC | 65 ms
9,856 KB |
testcase_42 | AC | 64 ms
9,472 KB |
testcase_43 | AC | 61 ms
9,728 KB |
testcase_44 | AC | 65 ms
9,856 KB |
testcase_45 | AC | 66 ms
9,728 KB |
testcase_46 | AC | 62 ms
9,600 KB |
testcase_47 | AC | 63 ms
9,728 KB |
testcase_48 | AC | 17 ms
6,784 KB |
testcase_49 | AC | 113 ms
13,824 KB |
testcase_50 | AC | 18 ms
6,784 KB |
testcase_51 | AC | 872 ms
5,376 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); bitset<150001> bit; rep(i, n){ cin >> a[i]; p[i] = {a[i], i}; bit.set(a[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; } rep(i, n){ bit.reset(a[i]); if((bit & (bit << a[i])).any()){ bitset<150001> bit2 = bit & (bit << a[i]); rep(j, 150001){ if(bit2.test(j)){ vi ans(n, 0); ans[i] = a[i]; ans[mp.find(j)->second] = -j; ans[mp.find(j - a[i])->second] = j - a[i]; CYES; rep(k, n){ cout << ans[k] << " "; } cout << endl; return 0; } } } bit.set(a[i]); } vi tmp; int kk = 1e7 / 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; }