結果

問題 No.2359 A in S ?
ユーザー t98slidert98slider
提出日時 2023-06-23 23:11:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 1,367 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 176,760 KB
実行使用メモリ 16,836 KB
最終ジャッジ日時 2023-09-13 18:20:09
合計ジャッジ時間 6,254 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
10,936 KB
testcase_01 AC 8 ms
11,008 KB
testcase_02 AC 9 ms
10,904 KB
testcase_03 AC 8 ms
11,036 KB
testcase_04 AC 186 ms
15,328 KB
testcase_05 AC 192 ms
13,792 KB
testcase_06 AC 185 ms
15,236 KB
testcase_07 AC 170 ms
12,264 KB
testcase_08 AC 196 ms
15,648 KB
testcase_09 AC 166 ms
16,496 KB
testcase_10 AC 166 ms
14,912 KB
testcase_11 AC 169 ms
14,900 KB
testcase_12 AC 185 ms
15,164 KB
testcase_13 AC 187 ms
15,156 KB
testcase_14 AC 183 ms
15,432 KB
testcase_15 AC 165 ms
16,632 KB
testcase_16 AC 191 ms
16,836 KB
testcase_17 AC 192 ms
16,760 KB
testcase_18 AC 193 ms
16,684 KB
testcase_19 AC 191 ms
16,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, mx = 100000;
    cin >> n >> m;
    int th = 320, x, y;
    vector<int> cnt(mx + 1);
    vector<vector<int>> cnt2(th, vector<int>(th));
    vector<vector<pair<int,int>>> tb(mx + 2); //加える
    vector<vector<pair<int,int>>> tb2(mx + 2); //削除
    vector<vector<int>> tb3(mx + 2); //クエリ
    for(int i = 0; i < n; i++){
        int l, r, x, y;
        cin >> l >> r >> x >> y;
        if(x < th){
            tb[l].emplace_back(x, y);
            tb2[r + 1].emplace_back(x, y);
        }else{
            while(y <= r){
                if(y >= l) cnt[y]++;
                y += x;
            }
        }
    }
    vector<int> b(m), ans(m);
    for(int i = 0; i < m; i++){
        cin >> b[i];
        tb3[b[i]].emplace_back(i);
    }

    for(int i = 0; i <= mx; i++){
        for(auto &&pa : tb[i]){
            tie(x, y) = pa;
            cnt2[x][y]++;
        }
        for(auto &&pa : tb2[i]){
            tie(x, y) = pa;
            cnt2[x][y]--;
        }
        for(auto &&qi : tb3[i]){
            for(int j = 1; j < th; j++){
                ans[qi] += cnt2[j][i % j];
            }
        }
    }

    for(int i = 0; i < m; i++){
        ans[i] += cnt[b[i]];
        cout << ans[i] << '\n'; 
    }
}
0