結果

問題 No.2359 A in S ?
ユーザー hiro71687khiro71687k
提出日時 2023-06-28 17:37:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 642 ms / 2,000 ms
コード長 2,067 bytes
コンパイル時間 8,564 ms
コンパイル使用メモリ 268,948 KB
実行使用メモリ 19,388 KB
最終ジャッジ日時 2023-09-18 21:39:49
合計ジャッジ時間 17,982 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,680 KB
testcase_01 AC 2 ms
4,624 KB
testcase_02 AC 6 ms
4,624 KB
testcase_03 AC 2 ms
4,628 KB
testcase_04 AC 587 ms
18,644 KB
testcase_05 AC 642 ms
18,484 KB
testcase_06 AC 586 ms
19,388 KB
testcase_07 AC 616 ms
19,244 KB
testcase_08 AC 615 ms
18,860 KB
testcase_09 AC 575 ms
18,264 KB
testcase_10 AC 586 ms
19,128 KB
testcase_11 AC 599 ms
18,064 KB
testcase_12 AC 584 ms
18,864 KB
testcase_13 AC 585 ms
18,080 KB
testcase_14 AC 588 ms
18,160 KB
testcase_15 AC 572 ms
18,792 KB
testcase_16 AC 591 ms
18,392 KB
testcase_17 AC 593 ms
19,168 KB
testcase_18 AC 597 ms
18,776 KB
testcase_19 AC 594 ms
18,404 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    }
    
}
0