結果

問題 No.854 公平なりんご分配
ユーザー DAyamaCTFDAyamaCTF
提出日時 2019-07-27 08:17:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,227 bytes
コンパイル時間 2,544 ms
コンパイル使用メモリ 165,736 KB
実行使用メモリ 88,452 KB
最終ジャッジ日時 2023-09-15 05:51:55
合計ジャッジ時間 21,200 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,944 KB
testcase_01 AC 5 ms
9,728 KB
testcase_02 AC 4 ms
9,660 KB
testcase_03 AC 4 ms
9,572 KB
testcase_04 AC 4 ms
9,516 KB
testcase_05 AC 5 ms
9,808 KB
testcase_06 AC 5 ms
9,636 KB
testcase_07 AC 5 ms
9,508 KB
testcase_08 AC 5 ms
9,636 KB
testcase_09 AC 4 ms
9,576 KB
testcase_10 AC 5 ms
9,516 KB
testcase_11 AC 5 ms
9,636 KB
testcase_12 AC 5 ms
9,696 KB
testcase_13 AC 6 ms
9,900 KB
testcase_14 AC 5 ms
9,660 KB
testcase_15 AC 5 ms
9,672 KB
testcase_16 AC 5 ms
9,628 KB
testcase_17 AC 6 ms
9,860 KB
testcase_18 AC 5 ms
9,676 KB
testcase_19 AC 5 ms
9,936 KB
testcase_20 AC 5 ms
9,652 KB
testcase_21 AC 5 ms
9,852 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<int> operator+(const vector<int>& a,const vector<int>& b){
  vector<int> res(a.size(),0);
  rep(i,a.size())res[i]=a[i]+b[i];
  return res;
}

bool isprime[2001];
vector<int> ps;
int M;
vector<int> calcvec(int X){
  vector<int> res(M,0);
  rep(i,ps.size()){
    while(X%ps[i]==0){
      res[i]++;
      X/=ps[i];
    }
  }
  return res;
}

struct RangeSumQuery{
  vector<int> dat[(1<<18)-1];
  int size;

  void init(int n_){
    size=1;
    while(size<n_) size*=2;
    for(int i=0;i<2*size-1;i++)dat[i]=vector<int>(M,0);
  }

  void update(int k,vector<int> a){
    k+=size-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=dat[k*2+1]+dat[k*2+2];
    }
  }

  vector<int> subquery(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return vector<int>(M,0);
    if(a<=l&&r<=b)return dat[k];
    else{
      return subquery(a,b,k*2+1,l,(l+r)/2)+subquery(a,b,k*2+2,(l+r)/2,r);
    }
  }
  
  vector<int> query(int a,int b){
    return subquery(a,b,0,0,size);
  }
};

int N,Q;
RangeSumQuery sgt;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  repl(i,2,2001)isprime[i]=true;
  for(ll i=2;i<=2000;i++){
    if(isprime[i]){
      ps.push_back(i);
      for(ll j=i*2;j<=2000;j+=i)isprime[j]=false;
    }
  }
  M=ps.size();

  cin>>N;
  sgt.init(N);
  rep(i,N){
    int A;
    cin>>A;
    vector<int> B=calcvec(A);
    sgt.update(i,B);
  }

  cin>>Q;
  rep(i,Q){
    int P,L,R;
    cin>>P>>L>>R;
    L--;
    vector<int> tmp=sgt.query(L,R);
    vector<int> p=calcvec(P);
    bool ok=true;
    rep(j,M)if(tmp[j]<p[j])ok=false;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }

  return 0;
}
0