結果
| 問題 |
No.2359 A in S ?
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-06-23 23:34:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 266 ms / 2,000 ms |
| コード長 | 1,254 bytes |
| コンパイル時間 | 1,168 ms |
| コンパイル使用メモリ | 100,104 KB |
| 実行使用メモリ | 15,148 KB |
| 最終ジャッジ日時 | 2024-07-01 03:22:08 |
| 合計ジャッジ時間 | 6,650 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#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';
}
hitonanode