結果
問題 |
No.1017 Reiwa Sequence
|
ユーザー |
![]() |
提出日時 | 2020-04-04 12:21:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
J_TLE
(最初)
|
実行時間 | - |
コード長 | 1,297 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 177,108 KB |
実行使用メモリ | 157,600 KB |
最終ジャッジ日時 | 2024-07-03 07:10:21 |
合計ジャッジ時間 | 27,747 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 13 WA * 23 TLE * 1 -- * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; int f(int a){ if(a%3<=1)return a%3; return -1; } int n; vector<int> v; typedef pair<int,int> P; void FIN(P a,P b){ cout<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<endl; cout<<"Yes"<<endl; int u=a.second,w=b.second; for(int i=0;i<n/2;i++){ cout<<v[i]*f(u)<<" "; u/=3; } for(int i=0;i<n-n/2;i++){ cout<<-v[n/2+i]*f(w)<<" "; w/=3; } for(int i=n;i<v.size();i++)cout<<0<<" "; cout<<endl; exit(0); } int pw(int n,int k){ assert(k>=0); int res=1; while(k){ if(k&1)res*=n; n*=n; k>>=1; } return res; } signed main(){ cin>>n; v.resize(n); for(int i=0;i<n;i++)cin>>v[i]; if(n>=32)n=32; set<P> s; for(int j=0;j<pw(3,n/2);j++){ int tmp=0,tmpj=j; for(int k=0;k<n/2;k++){ tmp+=v[k]*f(tmpj); tmpj/=3; } s.insert(P(tmp,j)); } for(int j=0;j<pw(3,n-n/2);j++){ int tmp=0,tmpj=j; for(int k=0;k<n-n/2;k++){ tmp+=v[n/2+k]*f(tmpj); tmpj/=3; } if(s.upper_bound(P(tmp,j))->first==tmp)FIN(*s.upper_bound(P(tmp,j)),P(tmp,j)); if((--s.lower_bound(P(tmp,j)))->first==tmp)FIN(*--s.lower_bound(P(tmp,j)),P(tmp,j)); if(j)if(s.lower_bound(P(tmp,j))->first==tmp)FIN(*s.lower_bound(P(tmp,j)),P(tmp,j)); } cout<<"No"<<endl; }