結果

問題 No.2359 A in S ?
ユーザー 蜜蜂蜜蜂
提出日時 2023-06-23 21:59:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,131 ms / 2,000 ms
コード長 1,827 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 170,220 KB
実行使用メモリ 142,644 KB
最終ジャッジ日時 2023-09-13 17:01:13
合計ジャッジ時間 18,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 188 ms
142,524 KB
testcase_01 AC 186 ms
142,644 KB
testcase_02 AC 194 ms
142,360 KB
testcase_03 AC 185 ms
142,372 KB
testcase_04 AC 1,115 ms
142,380 KB
testcase_05 AC 1,121 ms
142,444 KB
testcase_06 AC 1,131 ms
142,400 KB
testcase_07 AC 451 ms
142,384 KB
testcase_08 AC 493 ms
142,464 KB
testcase_09 AC 478 ms
142,396 KB
testcase_10 AC 478 ms
142,452 KB
testcase_11 AC 482 ms
142,448 KB
testcase_12 AC 1,105 ms
142,448 KB
testcase_13 AC 1,105 ms
142,448 KB
testcase_14 AC 1,115 ms
142,396 KB
testcase_15 AC 481 ms
142,364 KB
testcase_16 AC 1,096 ms
142,460 KB
testcase_17 AC 1,096 ms
142,536 KB
testcase_18 AC 1,117 ms
142,444 KB
testcase_19 AC 1,116 ms
142,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// g++ 1.cpp -std=c++17 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
 
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;
 
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

int mx = 1e5+1000;
int sq = 350;

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

  int n,m;cin>>n>>m;
  vvi v(sq+1,vi(mx,0));
  vi v2(mx,0);

  rep(i,0,n){
    int l,r,x,y;cin>>l>>r>>x>>y;
    if(x>=sq){
      int y2=y;
      while(y2<l){
        y2+=x;
      }
      while(y2<=r){
        v2[y2]++;
        y2+=x;
      }
    }
    else{
      int p=l/x,q=(r+1)/x;
      int p2=(p-5)*x+y,q2=(q-5)*x+y;
      while(p2<l)p2+=x;
      while(q2<=r)q2+=x;
      v[x][p2]++;
      v[x][q2]--;
    }
  }

  rep(i,1,sq+1){
    rep(j,0,mx){
      if(j>=i)v[i][j]+=v[i][j-i];
    }
  }

  rep(i,0,m){
    int a;cin>>a;
    int ans=0;
    rep(j,1,sq+1)ans+=v[j][a];
    ans+=v2[a];
    cout<<ans<<endl;
  }
}

/*
各条件に対し l <= a <= r かつ a = y ( mod x) となる a についてあらかじめ v[a] に 1 足しておく
各クエリはこののちに v[a] を返せばいい

int mx = 10^5
x_i >= sqrt(mx) 愚直に条件を満たす a に足していい
x_i <= sqrt(mx) imos もどきをする 各 x について加算操作は x 間隔で後で累積和を取る imos
*/
0