結果
| 問題 |
No.2359 A in S ?
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2023-06-23 21:57:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,827 bytes |
| コンパイル時間 | 1,689 ms |
| コンパイル使用メモリ | 172,272 KB |
| 実行使用メモリ | 149,628 KB |
| 最終ジャッジ日時 | 2024-07-01 01:34:25 |
| 合計ジャッジ時間 | 7,432 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 1 TLE * 1 -- * 14 |
ソースコード
// 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+=y;
}
while(y2<=r){
v2[y2]++;
y2+=y;
}
}
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
*/
蜜蜂