結果
問題 | No.1017 Reiwa Sequence |
ユーザー |
![]() |
提出日時 | 2020-04-03 22:06:36 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,920 bytes |
コンパイル時間 | 4,605 ms |
コンパイル使用メモリ | 150,580 KB |
最終ジャッジ日時 | 2025-01-09 13:03:09 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 49 TLE * 1 |
ソースコード
#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; vector<int> cnt(5000000,-1); int all = 1; rep(i,ml)all*=3; rep(i,all){ int tmp = i; int s = 2500000; int k=0; while(tmp){ int c=tmp%3; if(c==2)s-=a[k]; if(c==1)s+=a[k]; tmp/=3; ++k; } cnt[s]=i; } rep(i,mr-ml)all*=3; rep(i,all){ int tmp = i; int s = 2500000; 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(cnt[s]!=-1 && (cnt[s]!=0 ||i!=0)){ cout<<"Yes"<<endl; int t = cnt[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; }