結果
| 問題 |
No.2359 A in S ?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-23 22:40:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,146 bytes |
| コンパイル時間 | 1,892 ms |
| コンパイル使用メモリ | 206,952 KB |
| 最終ジャッジ日時 | 2025-02-15 01:20:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 TLE * 1 -- * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
return (a ? gcd(a, b % a) : b);
}
int main () {
int N, M;
cin >> N >> M;
std::vector<tuple<int, int, int, int>> X;
vector<int> cnt1(100010, 0);
const int H = 300;
vector<vector<vector<pair<int, int>>>> cnt2(H, vector<vector<pair<int, int>>>(H));
for (int i = 0; i < N; i ++) {
int l, r, x, y;
cin >> l >> r >> x >> y;
if (x < H) {
X.emplace_back(l, r, x, y);
} else {
for (int j = 0; j * x + y <= r; j ++) {
if (j * x + y >= l) cnt1[j * x + y] ++;
}
}
}
/*for (int i = 1; i < H; i ++) {
for (int j = 0; j < i; j ++) {
auto& a = cnt2[i][j];
a.emplace_back(-1, 0);
sort(a.begin(), a.end());
for (int k = 1; k < a.size(); k ++) {
a[k].second += a[k].second;
}
}
}*/
while (M --) {
int a;
cin >> a;
int ans = cnt1[a];
for (auto [l, r, x, y] : X) {
ans += (l <= a && a <= r && (a % x == y));
}
/*for (int i = 1; i < H; i ++) {
// auto pt = lower_bound(cnt2[i][a % i].begin(), cnt2[i][a % i].end(), make_pair(a + 1, -1));
ans += prev(pt) -> second;
}*/
cout << ans << endl;
}
}