結果
問題 | No.2359 A in S ? |
ユーザー |
![]() |
提出日時 | 2023-06-23 21:58:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,703 bytes |
コンパイル時間 | 2,394 ms |
コンパイル使用メモリ | 221,500 KB |
最終ジャッジ日時 | 2025-02-15 00:59:01 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>namespace {#pragma GCC diagnostic ignored "-Wunused-function"#include<atcoder/all>#pragma GCC diagnostic warning "-Wunused-function"using namespace std;using namespace atcoder;#define rep(i,n) for(int i = 0; i < (int)(n); i++)#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)#define all(x) begin(x), end(x)#define rall(x) rbegin(x), rend(x)template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }using ll = long long;using P = pair<int,int>;using VI = vector<int>;using VVI = vector<VI>;using VL = vector<ll>;using VVL = vector<VL>;constexpr int B = 320;constexpr int MX = 100010;} int main() {ios::sync_with_stdio(false);cin.tie(0);int n, m;cin >> n >> m;VI d(MX);vector<vector<tuple<int, int, int>>> lry(B);rep(_, n) {int l, r, x, y;cin >> l >> r >> x >> y;r++;if (x >= B) {// l <= y + kx < r// (l - y) / x <= k < (r - y) / xint klb = (l - y + x - 1) / x;int kub = (r - y + x - 1) / x;for(int k = klb; k < kub; k++) {d[y + k * x]++;}} else {lry[x].emplace_back(l, r, y);}}VI t(MX);rep(x, B) if (x) {t.assign(MX, 0);for(auto [l, r, y] : lry[x]) {int klb = (l - y + x - 1) / x;int kub = (r - y + x - 1) / x;if (klb == kub) continue;t[y + klb * x]++;if (y + kub * x < MX) t[y + kub * x]--;}rep(i, MX - x) t[i + x] += t[i];rep(i, MX) d[i] += t[i];}rep(_, m) {int a;cin >> a;cout << d[a] << '\n';}}