結果

問題 No.2359 A in S ?
ユーザー KudeKude
提出日時 2023-06-23 21:58:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,703 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 231,900 KB
実行使用メモリ 5,448 KB
最終ジャッジ日時 2023-09-13 16:59:39
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
4,380 KB
testcase_01 AC 37 ms
4,376 KB
testcase_02 AC 37 ms
4,380 KB
testcase_03 AC 37 ms
4,380 KB
testcase_04 AC 79 ms
5,288 KB
testcase_05 AC 85 ms
4,376 KB
testcase_06 AC 78 ms
5,112 KB
testcase_07 AC 86 ms
4,376 KB
testcase_08 AC 93 ms
4,940 KB
testcase_09 AC 78 ms
5,224 KB
testcase_10 AC 77 ms
4,380 KB
testcase_11 AC 80 ms
4,376 KB
testcase_12 AC 78 ms
5,244 KB
testcase_13 AC 77 ms
5,056 KB
testcase_14 AC 77 ms
5,448 KB
testcase_15 AC 77 ms
5,064 KB
testcase_16 AC 78 ms
4,984 KB
testcase_17 AC 77 ms
5,108 KB
testcase_18 AC 78 ms
5,132 KB
testcase_19 AC 79 ms
5,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) / x
      int 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';
  }
}
0