結果

問題 No.2359 A in S ?
ユーザー hiro71687k
提出日時 2023-06-28 17:37:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 665 ms / 2,000 ms
コード長 2,067 bytes
コンパイル時間 4,528 ms
コンパイル使用メモリ 260,512 KB
最終ジャッジ日時 2025-02-15 02:53:48
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=20000099999900;
ll mod=998244353;
int main(){
ll n,m;
cin >> n >> m;
vector<ll>l(n),r(n),x(n),y(n);
for (ll i = 0; i < n; i++)
{
cin >> l[i] >> r[i] >> x[i] >> y[i];
}
vector<ll>a(m);
for (ll i = 0; i < m; i++)
{
cin >> a[i];
}
vector<vector<ll>>b(300,vector<ll>(300,0));
vector<ll>c(100001,0);
vector<pair<ll,pair<ll,ll>>>p(m);
for (ll i = 0; i < m; i++)
{
p[i]={a[i],{i,i}};
}
for (ll i = 0; i < n; i++)
{
if (1)
{
p.push_back({l[i],{-inf,i}});
p.push_back({r[i],{inf,i}});
}
}
sort(p.begin(),p.end());
vector<ll>ans(m,0);
for (ll i = 0; i < p.size(); i++)
{
ll xx=p[i].first;
ll yy=p[i].second.first;
ll z=p[i].second.second;
if (yy==inf)
{
if (x[z]<300)
{
b[x[z]][y[z]]--;
}else{
ll now=y[z];
while (now<l[z])
{
now+=x[z];
}
while (now<=r[z])
{
c[now]--;
now+=x[z];
}
}
}else if (yy==-inf)
{
if (x[z]<300)
{
b[x[z]][y[z]]++;
}else{
ll now=y[z];
while (now<l[z])
{
now+=x[z];
}
while (now<=r[z])
{
c[now]++;
now+=x[z];
}
}
}else{
for (ll j = 1; j < 300; j++)
{
ll zz=xx%j;
ans[yy]+=b[j][zz];
}
ans[yy]+=c[xx];
}
}
for (ll i = 0; i < ans.size(); i++)
{
cout << ans[i] << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0