結果

問題 No.2359 A in S ?
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-07-21 11:20:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 207,636 KB
実行使用メモリ 14,928 KB
最終ジャッジ日時 2023-10-21 12:14:27
合計ジャッジ時間 7,963 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,432 KB
testcase_01 AC 4 ms
8,444 KB
testcase_02 AC 7 ms
8,868 KB
testcase_03 AC 5 ms
8,600 KB
testcase_04 AC 219 ms
12,084 KB
testcase_05 AC 299 ms
14,928 KB
testcase_06 AC 218 ms
12,100 KB
testcase_07 AC 169 ms
11,004 KB
testcase_08 AC 277 ms
13,808 KB
testcase_09 AC 248 ms
13,056 KB
testcase_10 AC 263 ms
13,804 KB
testcase_11 AC 278 ms
13,804 KB
testcase_12 AC 222 ms
12,080 KB
testcase_13 AC 219 ms
12,088 KB
testcase_14 AC 220 ms
12,200 KB
testcase_15 AC 249 ms
13,056 KB
testcase_16 AC 271 ms
13,684 KB
testcase_17 AC 273 ms
13,708 KB
testcase_18 AC 273 ms
13,712 KB
testcase_19 AC 274 ms
13,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using pii = pair<int, int>;
const int N = 1e5 + 10, B = 350;

int sc[B][B], lc[N];

int n, m, ans[N];
vector<pii> s[N];
vector<int> q[N];

int main() {
    cin >> n >> m;
    for(int i = 1, l, r, x, y; i <= n; i ++) {
        cin >> l >> r >> x >> y;
        s[l].push_back({x, y});
        s[r + 1].push_back({-x, y});
    }

    for(int i = 1, x; i <= m; i ++) {
        cin >> x;
        q[x].push_back(i);
    }

    for(int i = 1; i < N; i ++) {
        for(auto [p, x] : s[i]) {
            int w = 1;
            if(p < 0) {
                p = -p;
                w = -w;
            }
            if(p < B) sc[p][x] += w;
            else{
                for(int i = 0; i * p + x < N; i ++)
                    lc[i * p + x] += w;
            }
        }

        if(q[i].empty()) continue;
        
        int tot = lc[i];
        for(int j = 1; j < B; j ++)
            tot += sc[j][i % j];

        for(auto x : q[i]) {
            ans[x] = tot;
        }
    }

    for(int i = 1; i <= m; i ++)
        cout << ans[i] << "\n";
}
0