結果

問題 No.1017 Reiwa Sequence
ユーザー cureskolcureskol
提出日時 2020-04-04 12:23:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
J_TLE  
(最初)
実行時間 -
コード長 1,230 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 174,936 KB
実行使用メモリ 28,228 KB
最終ジャッジ日時 2023-09-16 05:36:41
合計ジャッジ時間 13,406 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,752 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 76 ms
11,600 KB
testcase_13 AC 346 ms
28,228 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 28 ms
4,376 KB
testcase_20 AC 29 ms
4,376 KB
testcase_21 AC 29 ms
4,440 KB
testcase_22 AC 28 ms
4,376 KB
testcase_23 AC 26 ms
4,380 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 24 ms
4,380 KB
testcase_26 AC 16 ms
4,376 KB
testcase_27 AC 16 ms
4,376 KB
testcase_28 AC 17 ms
4,376 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 6 ms
4,380 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 12 ms
4,380 KB
testcase_33 AC 7 ms
4,380 KB
testcase_34 AC 12 ms
4,540 KB
testcase_35 AC 6 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 14 ms
4,380 KB
testcase_38 AC 7 ms
4,376 KB
testcase_39 AC 14 ms
4,384 KB
testcase_40 TLE -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<<"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>=30)n=30;
  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;
}
0