結果

問題 No.3705 ビバ子とマカロン (Bibako and Macaron)
コンテスト
ユーザー UT0911
提出日時 2026-09-10 16:37:56
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 507 ms / 3,000 ms
+ 598µs
コード長 3,826 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,215 ms
コンパイル使用メモリ 392,276 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2026-09-10 16:38:27
合計ジャッジ時間 25,989 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
小課題1 10 % AC * 5
小課題2 30 % AC * 8
小課題3 60 % AC * 15
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using namespace std::chrono;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define ALL(x) (x).begin(), (x).end()
#define coutY cout << "Yes" << endl;
#define coutN cout << "No" << endl;
#define arrIn(arr, start, N) for (ll i = (start); i < (N); ++i) cin >> arr[i];
#define arrOut(arr, start, N) for  (ll i = (start); i < (N); ++i) { cout << arr[i]; if(i==(N)-1) cout << endl; else cout << " "; }
#define UNIQUE(A) sort(ALL(A)); A.erase(unique(ALL(A)),A.end());
#define mod9 998244353
#define mod1 1000000007
const int intM=numeric_limits<int>::max();
const ll llM=numeric_limits<ll>::max();
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string abc="abcdefghijklmnopqrstuvwxyz";
vi dx={0,-1,1,0};
vi dy={-1,0,0,1};
vi ddx={-1,0,1,-1,1,-1,0,1};
vi ddy={-1,-1,-1,0,0,1,1,1};

void yn(bool tf) { cout << (tf ? "Yes" : "No") << endl; }
void YN(bool tf) { cout << (tf ? "YES" : "NO") << endl; }

template<class T>
using priority_queueR = priority_queue<T, vector<T>, greater<T>>;

//cout << fixed << setprecision(20) <<

void arrOut2(auto A){
  for(auto x:A){
    for(auto y:x){
      cout << y << " ";
    }
    cout << endl;
  }
}

bool kaibun(string S){
  string T=S;
  reverse(ALL(S));
  return S==T;
}

int ketawa(int x){
  string S=to_string(x);
  int sum=0;
  int len=S.size();
  for(int i=0;i<len;i++){
    sum+=(int)(S[i]-'0');
  }
  return sum;
}

ll Power(ll a,ll b,ll m){
  ll ans=1,p=a;
  for(ll i=0;i<60;i++){
    if(b&(1LL<<i)){
      ans=(ans*p)%m;
    }
    p=(p*p)%m;
  }
  return ans;
}

ll ncr(ll n,ll r,ll m){
  if(r<=0||r>n)return 0;
  ll bunshi=1;
  for(ll i=1;i<=n;i++)bunshi=(bunshi*i)%m;

  ll bunbo=1;
  for(ll i=1;i<=r;i++)bunbo=(bunbo*i)%m;
  for(ll i=1;i<=n-r;i++)bunbo=(bunbo*i)%m;

  return (bunshi*Power(bunbo,m-2,m))%m;
}

// auto start = high_resolution_clock::now();

// ll getTime(){
//   auto end = high_resolution_clock::now();
//   return  duration_cast<milliseconds>(end - start).count();
// }

// bool CheckTime(auto limit,auto eps){
//   return  getTime()<limit-eps;
// }

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vl count(N+1,0);
  vl one(N+1,0);
  vl two(N+1,0);
  vl A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
    count[A[i]]++;
  }
  for(int i=1;i<=N;i++){
    if(count[i]>=1){
      one[i]=1;
      if(count[i]>=2){
        two[i]=1;
      }
    }
  }
  
  sort(ALL(A));
  for(int i=1;i<=N;i++){
    count[i]+=count[i-1];
    one[i]+=one[i-1];
    two[i]+=two[i-1];
  }
  int Q;
  cin >> Q;
  while(Q--){
    int L,R,L2,R2;
    cin >> L >> R >> L2 >> R2;
    int sameL=-1,sameR=-1,leftL,leftR,rightL,rightR;
    if(L<=L2&&R2<=R){
      sameL=L2;
      sameR=R2;
      leftL=L;
      leftR=L2-1;
      rightL=R2+1;
      rightR=R;
    }else if(L2<=L&&R<=R2){
      sameL=L;
      sameR=R;
      leftL=L2;
      leftR=L-1;
      rightL=R+1;
      rightR=R2;
    }else if(L<=L2&&L2<=R){
      sameL=L2;
      sameR=R;
      leftL=L;
      leftR=L2-1;
      rightL=R+1;
      rightR=R2;
    }else if(L2<=L&&L<=R2){
      sameL=L;
      sameR=R2;
      leftL=L2;
      leftR=L-1;
      rightL=R2+1;
      rightR=R;
    }else{
      leftL=min(L, L2);
      leftR=min(R, R2);
      rightL=max(L, L2);
      rightR=max(R, R2);
    }
    if(sameL!=-1){
      if(two[sameR]-two[sameL-1]!=sameR-sameL+1){
        coutN;
        continue;
      }
    }
    if(one[leftR]-one[leftL-1]!=leftR-leftL+1){
      coutN;
      continue;
    }
    if(one[rightR]-one[rightL-1]!=rightR-rightL+1){
      coutN;
      continue;
    }
    coutY;
  }
 
  return 0;
}
0