結果
問題 |
No.1017 Reiwa Sequence
|
ユーザー |
|
提出日時 | 2020-04-05 18:18:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,208 bytes |
コンパイル時間 | 1,642 ms |
コンパイル使用メモリ | 173,880 KB |
実行使用メモリ | 29,148 KB |
最終ジャッジ日時 | 2024-07-03 08:19:40 |
合計ジャッジ時間 | 36,083 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 RE * 43 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<ll,ll> PL; const ll MOD = 1e9 + 7; const ll INF = 1e10; const vector<int> dy = {-1,0,1,0}; const vector<int> dx = {0,1,0,-1}; int main() { int k; cin >> k; int n = min(22,k); vector<int> a(n); rep(i,n) cin >> a[i]; vector<vector<int>> tot(330005); for (int bit = 0;bit < (1 << n); bit ++ ) { int tmp = 0; rep(i,n) { if ((bit>>i)&1) { tmp += a[i]; } } tot[tmp].push_back(bit); } int p = 0,m = 0; for (int i = 1; i < 330005; i++) { if (tot[i].size() > 1) { p = tot[i][0]; m = tot[i][1]; break; } } if (p == 0) { cout << "No" << endl; return 0; } for (int i = 0; i < n; i ++) { if ((p>>i)&1 && (m>>i)&1) a[i] = 0; else if ((p>>i)&1) continue; else if ((m>>i)&1) a[i] = -a[i]; else a[i] = 0; } cout << "Yes" << endl; rep(i,n) cout << a[i] << ' '; rep(i,max(k - n,0)) cout << 0 << ' '; cout << '\n'; }