結果
| 問題 | No.3491 右結合的総乗 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-04 15:05:52 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 2,000 ms |
| コード長 | 741 bytes |
| 記録 | |
| コンパイル時間 | 1,472 ms |
| コンパイル使用メモリ | 214,320 KB |
| 実行使用メモリ | 68,972 KB |
| 最終ジャッジ日時 | 2026-04-04 15:06:00 |
| 合計ジャッジ時間 | 3,360 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000010, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];
int a[N];
bool st[N];
void solve() {
scanf("%d%d", &n, &m);
for (int i = 0; i < 2 * n + 1; i++) scanf("%d", a + i);
queue<int> q;
for (int i = 1; i < m + 1; i++) scanf("%d", w + i), q.push(w[i]);
while (q.size()) {
auto u = q.front(); q.pop();
if (st[u]) continue;
st[u] = 1;
for (int i = 1; i < m + 1; i++) q.push(a[u + w[i]]);
}
int res = 0;
for (int i = 0; i <= 2 * n; i++) res += st[i];
printf("%d\n", res);
}
int main() {
int T = 1;
// cin >> T;
while (T--) solve();
return 0;
}