結果

問題 No.2359 A in S ?
ユーザー 👑 hitonanodehitonanode
提出日時 2023-06-23 23:34:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,254 bytes
コンパイル時間 1,016 ms
コンパイル使用メモリ 99,484 KB
実行使用メモリ 15,116 KB
最終ジャッジ日時 2023-09-13 18:43:59
合計ジャッジ時間 6,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,508 KB
testcase_01 AC 5 ms
8,568 KB
testcase_02 AC 7 ms
8,520 KB
testcase_03 AC 5 ms
8,512 KB
testcase_04 AC 205 ms
13,544 KB
testcase_05 AC 244 ms
15,116 KB
testcase_06 AC 205 ms
13,528 KB
testcase_07 AC 194 ms
12,916 KB
testcase_08 AC 223 ms
14,304 KB
testcase_09 AC 191 ms
14,480 KB
testcase_10 AC 197 ms
14,244 KB
testcase_11 AC 200 ms
14,260 KB
testcase_12 AC 204 ms
13,460 KB
testcase_13 AC 206 ms
13,460 KB
testcase_14 AC 203 ms
13,368 KB
testcase_15 AC 190 ms
14,296 KB
testcase_16 AC 212 ms
14,532 KB
testcase_17 AC 213 ms
14,808 KB
testcase_18 AC 209 ms
14,908 KB
testcase_19 AC 212 ms
14,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <tuple>
#include <vector>
using namespace std;



int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    constexpr int B = 300;

    int N, M;
    cin >> N >> M;

    vector<vector<tuple<int, int, int>>> events(201010);

    while (N--) {
        int l, r, x, y;
        cin >> l >> r >> x >> y;

        events.at(l).emplace_back(0, x, y);
        events.at(r + 1).emplace_back(2, x, y);
    }

    for (int m = 0; m < M; ++m) {
        int a;
        cin >> a;
        events.at(a).emplace_back(1, m, a);
    }

    vector cntlo(B, vector<int>(B));
    vector<int> cnthi(101010);

    vector<int> ret(M);

    for (const auto &vec : events) {
        for (auto [tp, x, y] : vec) {
            if (tp == 1) {
                ret.at(x) += cnthi.at(y);
                for (int b = 1; b < B; ++b) ret.at(x) += cntlo.at(b).at(y % b);
            } else {
                if (x >= B) {
                    for (int i = y % x; i < int(cnthi.size()); i += x) {
                        cnthi.at(i) += tp == 0 ? 1 : -1;
                    }
                } else {
                    cntlo.at(x).at(y) += tp == 0 ? 1 : -1;
                }
            }
        }
    }

    for (auto x : ret) cout << x << '\n';
}
0