結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,448 KB
testcase_01 AC 4 ms
8,456 KB
testcase_02 WA -
testcase_03 AC 5 ms
8,616 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 170 ms
11,024 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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[B];

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