結果
| 問題 | No.1017 Reiwa Sequence |
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2020-04-03 22:01:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,894 bytes |
| 記録 | |
| コンパイル時間 | 1,646 ms |
| コンパイル使用メモリ | 123,832 KB |
| 最終ジャッジ日時 | 2025-01-09 12:59:49 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 TLE * 9 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int> a(n);
rep(i,n)cin>>a[i];
int m = min(30,n);
int ml = m/2, mr = (m+1)/2;
map<int,int> mp;
int all = 1;
rep(i,ml)all*=3;
rep(i,all){
int tmp = i;
int s = 0;
int k=0;
while(tmp){
int c=tmp%3;
if(c==2)s-=a[k];
if(c==1)s+=a[k];
tmp/=3;
++k;
}
mp[s]=i;
}
rep(i,mr-ml)all*=3;
rep(i,all){
int tmp = i;
int s = 0;
int k=ml;
while(tmp){
int c=tmp%3;
if(c==2)s+=a[k];
if(c==1)s-=a[k];
tmp/=3;
++k;
}
if(mp.count(s) && (mp[s]!=0 ||i!=0)){
cout<<"Yes"<<endl;
int t = mp[s];
rep(j,ml){
int c=t%3;
if(c==2)cout<<-a[j]<<" ";
else if(c==1)cout<<a[j]<<" ";
else cout<<"0 ";
t/=3;
}
rep(j,mr){
int c=i%3;
if(c==2)cout<<-a[ml+j]<<" ";
else if(c==1)cout<<a[ml+j]<<" ";
else cout<<"0 ";
i/=3;
}
rep(j,n-m)cout<<0<<" ";
cout<<endl;
return 0;
}
}
cout<<"No"<<endl;
return 0;
}
tempura_pp