結果
| 問題 |
No.1017 Reiwa Sequence
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-03 23:19:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 786 ms / 2,000 ms |
| コード長 | 1,021 bytes |
| コンパイル時間 | 3,675 ms |
| コンパイル使用メモリ | 201,064 KB |
| 最終ジャッジ日時 | 2025-01-09 13:44:18 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 50 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n;std::cin>>n;
std::vector<lint>a(n);
for(lint&x:a)std::cin>>x;
lint m=std::min(n,23ll);
lint M=1ll<<m;
std::map<lint,lint>map;
lint bs0=-1,bs1=-1;
for(lint bs=0;bs<M;bs++){
lint now=0;
for(lint i=0;i<m;i++){
if(!(bs>>i&1))continue;
now+=a.at(i);
}
auto found=map.find(now);
if(found!=map.end()){
bs0=found->second;
bs1=bs;
break;
}
map.emplace(now,bs);
}
if(bs0==-1){
std::cout<<"No"<<'\n';
return 0;
}
std::cout<<"Yes"<<'\n';
lint an=bs0^bs1;
bs0^=an,bs1^=an;
for(lint i=0;i<n;i++){
lint sign=m<=i?0:bs0>>i&1?+1:bs1>>i&1?-1:0;
std::cout<<(i?" ":"")<<sign*a.at(i);
}
std::cout<<'\n';
}
ngtkana